Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv10670
Modified Files:
Tag: rel-1_0
sockcheck.c
Log Message:
out of the blue.. we shouldnt have multiple threads screwing with the test lists..
should we?
Index: sockcheck.c
===================================================================
RCS file: /cvsroot/srvx/services/src/sockcheck.c,v
retrieving revision 1.54.2.32
retrieving revision 1.54.2.33
diff -C2 -r1.54.2.32 -r1.54.2.33
*** sockcheck.c 2001/09/30 04:03:55 1.54.2.32
--- sockcheck.c 2001/10/04 03:37:02 1.54.2.33
***************
*** 143,147 ****
--- 143,151 ----
};
+ /*
+ * List of tests protected by tests_mutex.
+ */
static struct sockcheck_list *tests;
+ static pthread_mutex_t tests_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Stuff used inside the worker thread, one instance per open connection. */
***************
*** 615,620 ****
log(PC_LOG, LOG_INFO, "Proxy check failed for client at IP %08x hostname %s (%s)\n", client->addr->addr, client->addr->hostname, client->addr->reason);
#endif
! /* Don't compare idx != 0 directly, because somebody else may have
! * reordered the tests already. */
if (client->tests->list[client->test_index] != tests->list[0]) {
struct sockcheck_list *new_tests = sockcheck_list_clone(tests);
--- 619,634 ----
log(PC_LOG, LOG_INFO, "Proxy check failed for client at IP %08x hostname %s (%s)\n", client->addr->addr, client->addr->hostname, client->addr->reason);
#endif
! /* protect the tests list with a mutex..
! * multiple threads shouldn't be rearranging the list
! * -Jedi
! */
! if (pthread_mutex_lock(&tests_mutex)) {
! /* lock failure; this usually means coding error */
! log(PC_LOG, LOG_ERROR, "BUG: pthread_mutex_lock(&tests_mutex) returned errno %d (%s)\n", errno, strerror(errno));
! return;
! }
!
! /* Don't compare idx != 0 directly, because somebody else may have
! * reordered the tests already. */
if (client->tests->list[client->test_index] != tests->list[0]) {
struct sockcheck_list *new_tests = sockcheck_list_clone(tests);
***************
*** 626,629 ****
--- 640,645 ----
tests = new_tests;
}
+
+ pthread_mutex_unlock(&tests_mutex);
} else {
log(PC_LOG, LOG_ERROR, "BUG: sockcheck_decide(\"%s\", %d): unrecognized decision\n", client->addr->hostname, decision);
|