From a06fca2ef6eb587778ef140dc4cb2692ffadf934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Thu, 6 Jun 2013 14:30:00 +0800 Subject: [PATCH] avoid close socket duplicate --- gate/mread.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gate/mread.c b/gate/mread.c index 5a8705d67..c0f53c67a 100644 --- a/gate/mread.c +++ b/gate/mread.c @@ -580,16 +580,20 @@ _link_node(struct ringbuffer * rb, int id, struct socket * s , struct ringbuffer void mread_close_client(struct mread_pool * self, int id) { struct socket * s = &self->sockets[id]; - s->status = SOCKET_HALFCLOSE; - try_close(self,s); + if (s->status >= SOCKET_ALIVE && s->status != SOCKET_HALFCLOSE) { + s->status = SOCKET_HALFCLOSE; + try_close(self, s); + } } static void force_close_client(struct mread_pool * self, int id) { struct socket * s = &self->sockets[id]; free_buffer(&s->client); - s->status = SOCKET_HALFCLOSE; - try_close(self, s); + if (s->status >= SOCKET_ALIVE && s->status != SOCKET_HALFCLOSE) { + s->status = SOCKET_HALFCLOSE; + try_close(self, s); + } } static void