X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fsysdep.c;h=26d132b5fe9270e6d2618204a723495a98281be5;hb=03707e73523860548f6dba876fb6c3c3d96f2b84;hp=8c9a12b212ab33f692db035c152d2ec21d3ae15b;hpb=10a4e4731822e568c9590db3135e0c43542bff8b;p=citadel.git diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 8c9a12b21..26d132b5f 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -67,7 +67,7 @@ pthread_mutex_t Critters[MAX_SEMAPHORES]; /* Things needing locking */ pthread_key_t MyConKey; /* TSD key for MyContext() */ int msock; /* master listening socket */ -int verbosity = 3; /* Logging level */ +int verbosity = 9; /* Logging level */ struct CitContext masterCC; @@ -433,13 +433,14 @@ void InitMyContext(struct CitContext *con) /* * Remove a context from the context list. */ -void RemoveContext(struct CitContext *con) +void RemoveContext(int con) { - struct CitContext *ptr; + struct CitContext *ptr = NULL; + struct CitContext *ToFree = NULL; lprintf(7, "Starting RemoveContext()\n"); - if (con==NULL) { - lprintf(7, "WARNING: RemoveContext() called with null!\n"); + if (con==0) { + lprintf(7, "WARNING: RemoveContext() called with 0!\n"); return; } @@ -448,21 +449,25 @@ void RemoveContext(struct CitContext *con) * so do not call it from within this loop. */ begin_critical_section(S_SESSION_TABLE); - lprintf(7, "Closing socket %d\n", con->client_socket); - close(con->client_socket); - if (ContextList==con) { + if (ContextList->client_socket == con) { + ToFree = ContextList; ContextList = ContextList->next; } else { for (ptr = ContextList; ptr != NULL; ptr = ptr->next) { - if (ptr->next == con) { - ptr->next = con->next; + if (ptr->next->client_socket == con) { + ToFree = ptr->next; + ptr->next = ptr->next->next; } } } - phree(con); + + lprintf(7, "Closing socket %d\n", ToFree->client_socket); + close(ToFree->client_socket); + phree(ToFree); + end_critical_section(S_SESSION_TABLE); lprintf(7, "Done with RemoveContext\n"); }