From: Art Cancro Date: Mon, 28 Aug 2023 00:40:34 +0000 (-0900) Subject: diagnostics X-Git-Tag: v989~34 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=b42ae74c4557d8cbf9c65713e972fc11fef3c4e1;p=citadel.git diagnostics --- diff --git a/citadel/server/threads.c b/citadel/server/threads.c index ea127ca15..ed229c19e 100644 --- a/citadel/server/threads.c +++ b/citadel/server/threads.c @@ -57,11 +57,14 @@ void begin_critical_section(int which_one) { cdb_check_handles(); } - //struct timeval t1,t2; - //gettimeofday(&t1, NULL); + struct timeval t1,t2; + syslog(LOG_DEBUG, "\033[33mthreads: lock %d requested\033[0m", which_one); + gettimeofday(&t1, NULL); + long ms1 = (t1.tv_sec * 1000) + t1.tv_usec; pthread_mutex_lock(&Critters[which_one]); - //gettimeofday(&t2, NULL); - //syslog(LOG_DEBUG, "threads: lock acquired in %ld milliseconds", ((t2.tv_sec*1000)+t2.tv_usec) - ((t1.tv_sec*1000)+t1.tv_usec) ); + gettimeofday(&t2, NULL); + long ms2 = (t2.tv_sec * 1000) + t2.tv_usec; + syslog(LOG_DEBUG, "\033[32mthreads: lock %d acquired in %ld milliseconds\033[0m", which_one, ms2-ms1); } @@ -69,6 +72,7 @@ void begin_critical_section(int which_one) { // Release a semaphore lock to end a critical section. void end_critical_section(int which_one) { pthread_mutex_unlock(&Critters[which_one]); + syslog(LOG_DEBUG, "\033[31mthreads: lock %d released\033[0m", which_one); } diff --git a/citadel/utils/loadtest.c b/citadel/utils/loadtest.c index c9cfba56d..0e6356a82 100644 --- a/citadel/utils/loadtest.c +++ b/citadel/utils/loadtest.c @@ -125,12 +125,12 @@ int uds_connectsock(char *sockpath) { s = socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) { - fprintf(stderr, "sendcommand: Can't create socket: %s\n", strerror(errno)); + fprintf(stderr, "loadtest: Can't create socket: %s\n", strerror(errno)); exit(3); } if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - fprintf(stderr, "sendcommand: can't connect: %s\n", strerror(errno)); + fprintf(stderr, "loadtest: can't connect: %s\n", strerror(errno)); close(s); exit(3); } @@ -277,39 +277,47 @@ void do_stuff(void) { int i; char buf[SIZ]; - printf("Creating test user '%s'\n", test_user); snprintf(buf, sizeof buf, "CREU %s", test_user); + printf("< %s\n", buf); serv_puts(buf); serv_gets(buf); - printf("%s\n", buf); + printf("> %s\n", buf); snprintf(buf, sizeof buf, "ASUP %s|640k_enough_ne1|0|||6|", test_user); + printf("< %s\n", buf); serv_puts(buf); serv_gets(buf); - printf("%s\n", buf); + printf("> %s\n", buf); snprintf(buf, sizeof buf, "USER %s", test_user); + printf("< %s\n", buf); serv_puts(buf); serv_gets(buf); - printf("%s\n", buf); + printf("> %s\n", buf); snprintf(buf, sizeof buf, "PASS 640k_enough_ne1"); + printf("< %s\n", buf); serv_puts(buf); serv_gets(buf); - printf("%s\n", buf); + printf("> %s\n", buf); for (i=0; i %s\n", buf); } snprintf(buf, sizeof(buf), "GOTO %s", random_rooms[0]); + printf("< %s\n", buf); serv_puts(buf); serv_gets(buf); - printf("%s\n", buf); + printf("> %s\n", buf); + long ops = 0; while(1) { + alarm(30); perform_random_thing(); + printf(" \033[32mOperations completed: \033[33m%ld\033[0m\r", ++ops); + fflush(stdout); } } @@ -328,25 +336,25 @@ int main(int argc, char **argv) { strncpy(ctdldir, optarg, sizeof ctdldir); break; default: - fprintf(stderr, "sendcommand: usage: %s [-h server_dir]\n", argv[0]); + fprintf(stderr, "loadtest: usage: %s [-h server_dir]\n", argv[0]); return(1); } } - fprintf(stderr, "sendcommand: started (pid=%d) connecting to Citadel server with data directory %s\n", + fprintf(stderr, "loadtest: started (pid=%d) connecting to Citadel server with data directory %s\n", (int) getpid(), ctdldir ); fflush(stderr); if (chdir(ctdldir) != 0) { - fprintf(stderr, "sendcommand: %s: %s\n", ctdldir, strerror(errno)); + fprintf(stderr, "loadtest: %s: %s\n", ctdldir, strerror(errno)); exit(errno); } serv_sock = uds_connectsock(file_citadel_admin_socket); serv_gets(buf); - fprintf(stderr, "%s\n", buf); + printf("> %s\n", buf); do_stuff();