@@ -381,7 +381,7 @@ get_status_text()
381
381
pstr_t * pstr = pstr_new ();
382
382
s_config * config ;
383
383
t_auth_serv * auth_server ;
384
- t_client * first ;
384
+ t_client * sublist , * current ;
385
385
int count ;
386
386
time_t uptime = 0 ;
387
387
unsigned int days = 0 , hours = 0 , minutes = 0 , seconds = 0 ;
@@ -414,35 +414,26 @@ get_status_text()
414
414
415
415
LOCK_CLIENT_LIST ();
416
416
417
- first = client_get_first_client ( );
417
+ count = client_list_dup ( & sublist );
418
418
419
- if (first == NULL ) {
420
- count = 0 ;
421
- } else {
422
- count = 1 ;
423
- while (first -> next != NULL ) {
424
- first = first -> next ;
425
- count ++ ;
426
- }
427
- }
419
+ UNLOCK_CLIENT_LIST ();
428
420
429
- pstr_append_sprintf ( pstr , "%d clients " "connected.\n" , count ) ;
421
+ current = sublist ;
430
422
431
- first = client_get_first_client ( );
423
+ pstr_append_sprintf ( pstr , "%d clients " "connected.\n" , count );
432
424
433
- count = 0 ;
434
- while (first != NULL ) {
425
+ count = 1 ;
426
+ while (current != NULL ) {
435
427
pstr_append_sprintf (pstr , "\nClient %d\n" , count );
436
- pstr_append_sprintf (pstr , " IP: %s MAC: %s\n" , first -> ip , first -> mac );
437
- pstr_append_sprintf (pstr , " Token: %s\n" , first -> token );
438
- pstr_append_sprintf (pstr , " Downloaded: %llu\n Uploaded: %llu\n" , first -> counters .incoming ,
439
- first -> counters .outgoing );
440
-
428
+ pstr_append_sprintf (pstr , " IP: %s MAC: %s\n" , current -> ip , current -> mac );
429
+ pstr_append_sprintf (pstr , " Token: %s\n" , current -> token );
430
+ pstr_append_sprintf (pstr , " Downloaded: %llu\n Uploaded: %llu\n" , current -> counters .incoming ,
431
+ current -> counters .outgoing );
441
432
count ++ ;
442
- first = first -> next ;
433
+ current = current -> next ;
443
434
}
444
435
445
- UNLOCK_CLIENT_LIST ( );
436
+ client_list_destroy ( sublist );
446
437
447
438
config = config_get_config ();
448
439
0 commit comments