id reserve bugfix

This commit is contained in:
云风
2013-10-08 10:26:25 +08:00
parent e402d114bf
commit ec4ae98536

View File

@@ -123,7 +123,7 @@ reverve_id(struct socket_server *ss) {
for (i=0;i<MAX_SOCKET;i++) { for (i=0;i<MAX_SOCKET;i++) {
int id = __sync_add_and_fetch(&(ss->alloc_id), 1); int id = __sync_add_and_fetch(&(ss->alloc_id), 1);
if (id < 0) { if (id < 0) {
id = __sync_fetch_and_and(&(ss->alloc_id), 0x7fffffff); id = __sync_and_and_fetch(&(ss->alloc_id), 0x7fffffff);
} }
struct socket *s = &ss->slot[id % MAX_SOCKET]; struct socket *s = &ss->slot[id % MAX_SOCKET];
if (s->type == SOCKET_TYPE_INVALID) { if (s->type == SOCKET_TYPE_INVALID) {