| 3 |
* user_list |
* user_list |
| 4 |
* - data model and basic operations of (online) user list |
* - data model and basic operations of (online) user list |
| 5 |
* |
* |
| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
| 152 |
|
|
| 153 |
if (db == NULL || p_list == NULL) |
if (db == NULL || p_list == NULL) |
| 154 |
{ |
{ |
| 155 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 156 |
return -1; |
return -1; |
| 157 |
} |
} |
| 158 |
|
|
| 175 |
|
|
| 176 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 177 |
{ |
{ |
| 178 |
log_error("Query user info error: %s\n", mysql_error(db)); |
log_error("Query user info error: %s", mysql_error(db)); |
| 179 |
ret = -1; |
ret = -1; |
| 180 |
goto cleanup; |
goto cleanup; |
| 181 |
} |
} |
| 182 |
|
|
| 183 |
if ((rs = mysql_use_result(db)) == NULL) |
if ((rs = mysql_use_result(db)) == NULL) |
| 184 |
{ |
{ |
| 185 |
log_error("Get user info data failed\n"); |
log_error("Get user info data failed"); |
| 186 |
ret = -1; |
ret = -1; |
| 187 |
goto cleanup; |
goto cleanup; |
| 188 |
} |
} |
| 210 |
intro_len = strlen((row[12] == NULL ? "" : row[12])); |
intro_len = strlen((row[12] == NULL ? "" : row[12])); |
| 211 |
if (intro_len >= sizeof(p_list->user_intro_buf) - 1 - intro_buf_offset) |
if (intro_len >= sizeof(p_list->user_intro_buf) - 1 - intro_buf_offset) |
| 212 |
{ |
{ |
| 213 |
log_error("OOM for user introduction: len=%d, i=%d\n", intro_len, i); |
log_error("OOM for user introduction: len=%d, i=%d", intro_len, i); |
| 214 |
break; |
break; |
| 215 |
} |
} |
| 216 |
memcpy(p_list->user_intro_buf + intro_buf_offset, |
memcpy(p_list->user_intro_buf + intro_buf_offset, |
| 222 |
i++; |
i++; |
| 223 |
if (i >= BBS_max_user_count) |
if (i >= BBS_max_user_count) |
| 224 |
{ |
{ |
| 225 |
log_error("Too many users, exceed limit %d\n", BBS_max_user_count); |
log_error("Too many users, exceed limit %d", BBS_max_user_count); |
| 226 |
break; |
break; |
| 227 |
} |
} |
| 228 |
} |
} |
| 240 |
|
|
| 241 |
qsort(p_list->index_uid, (size_t)i, sizeof(USER_INFO_INDEX_UID), user_info_index_uid_comp); |
qsort(p_list->index_uid, (size_t)i, sizeof(USER_INFO_INDEX_UID), user_info_index_uid_comp); |
| 242 |
|
|
| 243 |
log_debug("Rebuild index of %d users, last_uid=%d\n", i, p_list->users[i - 1].uid); |
log_debug("Rebuild index of %d users, last_uid=%d", i, p_list->users[i - 1].uid); |
| 244 |
} |
} |
| 245 |
|
|
| 246 |
p_list->user_count = i; |
p_list->user_count = i; |
| 247 |
|
|
| 248 |
log_debug("Loaded %d users\n", p_list->user_count); |
log_debug("Loaded %d users", p_list->user_count); |
| 249 |
|
|
| 250 |
cleanup: |
cleanup: |
| 251 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 266 |
|
|
| 267 |
if (db == NULL || p_online_list == NULL) |
if (db == NULL || p_online_list == NULL) |
| 268 |
{ |
{ |
| 269 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 270 |
return -1; |
return -1; |
| 271 |
} |
} |
| 272 |
|
|
| 279 |
|
|
| 280 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 281 |
{ |
{ |
| 282 |
log_error("Query user online error: %s\n", mysql_error(db)); |
log_error("Query user online error: %s", mysql_error(db)); |
| 283 |
ret = -1; |
ret = -1; |
| 284 |
goto cleanup; |
goto cleanup; |
| 285 |
} |
} |
| 286 |
|
|
| 287 |
if ((rs = mysql_use_result(db)) == NULL) |
if ((rs = mysql_use_result(db)) == NULL) |
| 288 |
{ |
{ |
| 289 |
log_error("Get user online data failed\n"); |
log_error("Get user online data failed"); |
| 290 |
ret = -1; |
ret = -1; |
| 291 |
goto cleanup; |
goto cleanup; |
| 292 |
} |
} |
| 312 |
|
|
| 313 |
if ((ret = query_user_info_by_uid(atoi(row[1]), &(p_online_list->users[i].user_info), NULL, 0)) <= 0) |
if ((ret = query_user_info_by_uid(atoi(row[1]), &(p_online_list->users[i].user_info), NULL, 0)) <= 0) |
| 314 |
{ |
{ |
| 315 |
log_error("query_user_info_by_uid(%d) error\n", atoi(row[1])); |
log_error("query_user_info_by_uid(%d) error", atoi(row[1])); |
| 316 |
continue; |
continue; |
| 317 |
} |
} |
| 318 |
|
|
| 328 |
} |
} |
| 329 |
else if (trie_dict_get(p_trie_action_dict, p_online_list->users[i].current_action, (int64_t *)(&(p_online_list->users[i].current_action_title))) < 0) |
else if (trie_dict_get(p_trie_action_dict, p_online_list->users[i].current_action, (int64_t *)(&(p_online_list->users[i].current_action_title))) < 0) |
| 330 |
{ |
{ |
| 331 |
log_error("trie_dict_get(p_trie_action_dict, %s) error on session_id=%s\n", |
log_error("trie_dict_get(p_trie_action_dict, %s) error on session_id=%s", |
| 332 |
p_online_list->users[i].current_action, p_online_list->users[i].session_id); |
p_online_list->users[i].current_action, p_online_list->users[i].session_id); |
| 333 |
continue; |
continue; |
| 334 |
} |
} |
| 339 |
i++; |
i++; |
| 340 |
if (i >= BBS_max_user_online_count) |
if (i >= BBS_max_user_online_count) |
| 341 |
{ |
{ |
| 342 |
log_error("Too many online users, exceed limit %d\n", BBS_max_user_online_count); |
log_error("Too many online users, exceed limit %d", BBS_max_user_online_count); |
| 343 |
break; |
break; |
| 344 |
} |
} |
| 345 |
} |
} |
| 375 |
|
|
| 376 |
if (db == NULL) |
if (db == NULL) |
| 377 |
{ |
{ |
| 378 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 379 |
return -1; |
return -1; |
| 380 |
} |
} |
| 381 |
|
|
| 383 |
"SELECT ID FROM user_login_log ORDER BY ID DESC LIMIT 1"); |
"SELECT ID FROM user_login_log ORDER BY ID DESC LIMIT 1"); |
| 384 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 385 |
{ |
{ |
| 386 |
log_error("Query user_login_log error: %s\n", mysql_error(db)); |
log_error("Query user_login_log error: %s", mysql_error(db)); |
| 387 |
return -2; |
return -2; |
| 388 |
} |
} |
| 389 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 390 |
{ |
{ |
| 391 |
log_error("Get user_login_log data failed\n"); |
log_error("Get user_login_log data failed"); |
| 392 |
return -2; |
return -2; |
| 393 |
} |
} |
| 394 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 416 |
|
|
| 417 |
if (p_user_list_pool != NULL || p_trie_action_dict != NULL) |
if (p_user_list_pool != NULL || p_trie_action_dict != NULL) |
| 418 |
{ |
{ |
| 419 |
log_error("p_user_list_pool already initialized\n"); |
log_error("p_user_list_pool already initialized"); |
| 420 |
return -1; |
return -1; |
| 421 |
} |
} |
| 422 |
|
|
| 423 |
p_trie_action_dict = trie_dict_create(); |
p_trie_action_dict = trie_dict_create(); |
| 424 |
if (p_trie_action_dict == NULL) |
if (p_trie_action_dict == NULL) |
| 425 |
{ |
{ |
| 426 |
log_error("trie_dict_create() error\n"); |
log_error("trie_dict_create() error"); |
| 427 |
return -1; |
return -1; |
| 428 |
} |
} |
| 429 |
|
|
| 431 |
{ |
{ |
| 432 |
if (trie_dict_set(p_trie_action_dict, user_action_map[i].name, (int64_t)(user_action_map[i].title)) < 0) |
if (trie_dict_set(p_trie_action_dict, user_action_map[i].name, (int64_t)(user_action_map[i].title)) < 0) |
| 433 |
{ |
{ |
| 434 |
log_error("trie_dict_set(p_trie_action_dict, %s) error\n", user_action_map[i].name); |
log_error("trie_dict_set(p_trie_action_dict, %s) error", user_action_map[i].name); |
| 435 |
} |
} |
| 436 |
} |
} |
| 437 |
|
|
| 444 |
|
|
| 445 |
if (shm_unlink(user_list_shm_name) == -1 && errno != ENOENT) |
if (shm_unlink(user_list_shm_name) == -1 && errno != ENOENT) |
| 446 |
{ |
{ |
| 447 |
log_error("shm_unlink(%s) error (%d)\n", user_list_shm_name, errno); |
log_error("shm_unlink(%s) error (%d)", user_list_shm_name, errno); |
| 448 |
return -2; |
return -2; |
| 449 |
} |
} |
| 450 |
|
|
| 451 |
if ((fd = shm_open(user_list_shm_name, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) |
if ((fd = shm_open(user_list_shm_name, O_CREAT | O_EXCL | O_RDWR, 0600)) == -1) |
| 452 |
{ |
{ |
| 453 |
log_error("shm_open(%s) error (%d)\n", user_list_shm_name, errno); |
log_error("shm_open(%s) error (%d)", user_list_shm_name, errno); |
| 454 |
return -2; |
return -2; |
| 455 |
} |
} |
| 456 |
if (ftruncate(fd, (off_t)size) == -1) |
if (ftruncate(fd, (off_t)size) == -1) |
| 457 |
{ |
{ |
| 458 |
log_error("ftruncate(size=%d) error (%d)\n", size, errno); |
log_error("ftruncate(size=%d) error (%d)", size, errno); |
| 459 |
close(fd); |
close(fd); |
| 460 |
return -2; |
return -2; |
| 461 |
} |
} |
| 463 |
p_shm = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0L); |
p_shm = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0L); |
| 464 |
if (p_shm == MAP_FAILED) |
if (p_shm == MAP_FAILED) |
| 465 |
{ |
{ |
| 466 |
log_error("mmap() error (%d)\n", errno); |
log_error("mmap() error (%d)", errno); |
| 467 |
close(fd); |
close(fd); |
| 468 |
return -2; |
return -2; |
| 469 |
} |
} |
| 470 |
|
|
| 471 |
if (close(fd) < 0) |
if (close(fd) < 0) |
| 472 |
{ |
{ |
| 473 |
log_error("close(fd) error (%d)\n", errno); |
log_error("close(fd) error (%d)", errno); |
| 474 |
return -1; |
return -1; |
| 475 |
} |
} |
| 476 |
|
|
| 481 |
#ifndef HAVE_SYSTEM_V |
#ifndef HAVE_SYSTEM_V |
| 482 |
if (sem_init(&(p_user_list_pool->sem), 1, 1) == -1) |
if (sem_init(&(p_user_list_pool->sem), 1, 1) == -1) |
| 483 |
{ |
{ |
| 484 |
log_error("sem_init() error (%d)\n", errno); |
log_error("sem_init() error (%d)", errno); |
| 485 |
return -3; |
return -3; |
| 486 |
} |
} |
| 487 |
|
|
| 492 |
key = ftok(filename, proj_id); |
key = ftok(filename, proj_id); |
| 493 |
if (key == -1) |
if (key == -1) |
| 494 |
{ |
{ |
| 495 |
log_error("ftok(%s %d) error (%d)\n", filename, proj_id, errno); |
log_error("ftok(%s %d) error (%d)", filename, proj_id, errno); |
| 496 |
return -2; |
return -2; |
| 497 |
} |
} |
| 498 |
|
|
| 500 |
semid = semget(key, (int)size, IPC_CREAT | IPC_EXCL | 0600); |
semid = semget(key, (int)size, IPC_CREAT | IPC_EXCL | 0600); |
| 501 |
if (semid == -1) |
if (semid == -1) |
| 502 |
{ |
{ |
| 503 |
log_error("semget(user_list_pool_sem, size = %d) error (%d)\n", size, errno); |
log_error("semget(user_list_pool_sem, size = %d) error (%d)", size, errno); |
| 504 |
return -3; |
return -3; |
| 505 |
} |
} |
| 506 |
|
|
| 510 |
{ |
{ |
| 511 |
if (semctl(semid, i, SETVAL, arg) == -1) |
if (semctl(semid, i, SETVAL, arg) == -1) |
| 512 |
{ |
{ |
| 513 |
log_error("semctl(user_list_pool_sem, SETVAL) error (%d)\n", errno); |
log_error("semctl(user_list_pool_sem, SETVAL) error (%d)", errno); |
| 514 |
return -3; |
return -3; |
| 515 |
} |
} |
| 516 |
} |
} |
| 543 |
#ifdef HAVE_SYSTEM_V |
#ifdef HAVE_SYSTEM_V |
| 544 |
if (semctl(p_user_list_pool->semid, 0, IPC_RMID) == -1) |
if (semctl(p_user_list_pool->semid, 0, IPC_RMID) == -1) |
| 545 |
{ |
{ |
| 546 |
log_error("semctl(semid = %d, IPC_RMID) error (%d)\n", p_user_list_pool->semid, errno); |
log_error("semctl(semid = %d, IPC_RMID) error (%d)", p_user_list_pool->semid, errno); |
| 547 |
} |
} |
| 548 |
#else |
#else |
| 549 |
if (sem_destroy(&(p_user_list_pool->sem)) == -1) |
if (sem_destroy(&(p_user_list_pool->sem)) == -1) |
| 550 |
{ |
{ |
| 551 |
log_error("sem_destroy() error (%d)\n", errno); |
log_error("sem_destroy() error (%d)", errno); |
| 552 |
} |
} |
| 553 |
#endif |
#endif |
| 554 |
|
|
| 556 |
|
|
| 557 |
if (shm_unlink(user_list_shm_name) == -1 && errno != ENOENT) |
if (shm_unlink(user_list_shm_name) == -1 && errno != ENOENT) |
| 558 |
{ |
{ |
| 559 |
log_error("shm_unlink(%s) error (%d)\n", user_list_shm_name, errno); |
log_error("shm_unlink(%s) error (%d)", user_list_shm_name, errno); |
| 560 |
} |
} |
| 561 |
|
|
| 562 |
user_list_shm_name[0] = '\0'; |
user_list_shm_name[0] = '\0'; |
| 573 |
{ |
{ |
| 574 |
if (p_user_list_pool != NULL && mprotect(p_user_list_pool, p_user_list_pool->shm_size, PROT_READ) < 0) |
if (p_user_list_pool != NULL && mprotect(p_user_list_pool, p_user_list_pool->shm_size, PROT_READ) < 0) |
| 575 |
{ |
{ |
| 576 |
log_error("mprotect() error (%d)\n", errno); |
log_error("mprotect() error (%d)", errno); |
| 577 |
return -1; |
return -1; |
| 578 |
} |
} |
| 579 |
|
|
| 584 |
{ |
{ |
| 585 |
if (p_user_list_pool != NULL && munmap(p_user_list_pool, p_user_list_pool->shm_size) < 0) |
if (p_user_list_pool != NULL && munmap(p_user_list_pool, p_user_list_pool->shm_size) < 0) |
| 586 |
{ |
{ |
| 587 |
log_error("munmap() error (%d)\n", errno); |
log_error("munmap() error (%d)", errno); |
| 588 |
return -1; |
return -1; |
| 589 |
} |
} |
| 590 |
|
|
| 601 |
|
|
| 602 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 603 |
{ |
{ |
| 604 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 605 |
return -1; |
return -1; |
| 606 |
} |
} |
| 607 |
|
|
| 608 |
db = db_open(); |
db = db_open(); |
| 609 |
if (db == NULL) |
if (db == NULL) |
| 610 |
{ |
{ |
| 611 |
log_error("db_open() error: %s\n", mysql_error(db)); |
log_error("db_open() error: %s", mysql_error(db)); |
| 612 |
return -1; |
return -1; |
| 613 |
} |
} |
| 614 |
|
|
| 616 |
{ |
{ |
| 617 |
if (user_online_list_load(db, &(p_user_list_pool->user_online_list[p_user_list_pool->user_online_list_index_new])) < 0) |
if (user_online_list_load(db, &(p_user_list_pool->user_online_list[p_user_list_pool->user_online_list_index_new])) < 0) |
| 618 |
{ |
{ |
| 619 |
log_error("user_online_list_load() error\n"); |
log_error("user_online_list_load() error"); |
| 620 |
ret = -2; |
ret = -2; |
| 621 |
goto cleanup; |
goto cleanup; |
| 622 |
} |
} |
| 623 |
|
|
| 624 |
if (user_login_count_load(db) < 0) |
if (user_login_count_load(db) < 0) |
| 625 |
{ |
{ |
| 626 |
log_error("user_login_count_load() error\n"); |
log_error("user_login_count_load() error"); |
| 627 |
ret = -2; |
ret = -2; |
| 628 |
goto cleanup; |
goto cleanup; |
| 629 |
} |
} |
| 632 |
{ |
{ |
| 633 |
if (user_list_load(db, &(p_user_list_pool->user_list[p_user_list_pool->user_list_index_new])) < 0) |
if (user_list_load(db, &(p_user_list_pool->user_list[p_user_list_pool->user_list_index_new])) < 0) |
| 634 |
{ |
{ |
| 635 |
log_error("user_list_load() error\n"); |
log_error("user_list_load() error"); |
| 636 |
ret = -2; |
ret = -2; |
| 637 |
goto cleanup; |
goto cleanup; |
| 638 |
} |
} |
| 643 |
|
|
| 644 |
if (user_list_rw_lock() < 0) |
if (user_list_rw_lock() < 0) |
| 645 |
{ |
{ |
| 646 |
log_error("user_list_rw_lock() error\n"); |
log_error("user_list_rw_lock() error"); |
| 647 |
ret = -3; |
ret = -3; |
| 648 |
goto cleanup; |
goto cleanup; |
| 649 |
} |
} |
| 665 |
|
|
| 666 |
if (user_list_rw_unlock() < 0) |
if (user_list_rw_unlock() < 0) |
| 667 |
{ |
{ |
| 668 |
log_error("user_list_rw_unlock() error\n"); |
log_error("user_list_rw_unlock() error"); |
| 669 |
ret = -3; |
ret = -3; |
| 670 |
goto cleanup; |
goto cleanup; |
| 671 |
} |
} |
| 686 |
|
|
| 687 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 688 |
{ |
{ |
| 689 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 690 |
return -1; |
return -1; |
| 691 |
} |
} |
| 692 |
|
|
| 705 |
ret = semtimedop(p_user_list_pool->semid, sops, 2, &timeout); |
ret = semtimedop(p_user_list_pool->semid, sops, 2, &timeout); |
| 706 |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
| 707 |
{ |
{ |
| 708 |
log_error("semop(lock read) error %d\n", errno); |
log_error("semop(lock read) error %d", errno); |
| 709 |
} |
} |
| 710 |
#else |
#else |
| 711 |
if (sem_timedwait(&(p_user_list_pool->sem), &timeout) == -1) |
if (sem_timedwait(&(p_user_list_pool->sem), &timeout) == -1) |
| 712 |
{ |
{ |
| 713 |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
| 714 |
{ |
{ |
| 715 |
log_error("sem_timedwait() error %d\n", errno); |
log_error("sem_timedwait() error %d", errno); |
| 716 |
} |
} |
| 717 |
return -1; |
return -1; |
| 718 |
} |
} |
| 729 |
|
|
| 730 |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
| 731 |
{ |
{ |
| 732 |
log_error("sem_post() error %d\n", errno); |
log_error("sem_post() error %d", errno); |
| 733 |
return -1; |
return -1; |
| 734 |
} |
} |
| 735 |
#endif |
#endif |
| 747 |
|
|
| 748 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 749 |
{ |
{ |
| 750 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 751 |
return -1; |
return -1; |
| 752 |
} |
} |
| 753 |
|
|
| 770 |
ret = semtimedop(p_user_list_pool->semid, sops, 3, &timeout); |
ret = semtimedop(p_user_list_pool->semid, sops, 3, &timeout); |
| 771 |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
| 772 |
{ |
{ |
| 773 |
log_error("semop(lock write) error %d\n", errno); |
log_error("semop(lock write) error %d", errno); |
| 774 |
} |
} |
| 775 |
#else |
#else |
| 776 |
if (sem_timedwait(&(p_user_list_pool->sem), &timeout) == -1) |
if (sem_timedwait(&(p_user_list_pool->sem), &timeout) == -1) |
| 777 |
{ |
{ |
| 778 |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
| 779 |
{ |
{ |
| 780 |
log_error("sem_timedwait() error %d\n", errno); |
log_error("sem_timedwait() error %d", errno); |
| 781 |
} |
} |
| 782 |
return -1; |
return -1; |
| 783 |
} |
} |
| 794 |
|
|
| 795 |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
| 796 |
{ |
{ |
| 797 |
log_error("sem_post() error %d\n", errno); |
log_error("sem_post() error %d", errno); |
| 798 |
return -1; |
return -1; |
| 799 |
} |
} |
| 800 |
#endif |
#endif |
| 811 |
|
|
| 812 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 813 |
{ |
{ |
| 814 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 815 |
return -1; |
return -1; |
| 816 |
} |
} |
| 817 |
|
|
| 823 |
ret = semop(p_user_list_pool->semid, sops, 1); |
ret = semop(p_user_list_pool->semid, sops, 1); |
| 824 |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
| 825 |
{ |
{ |
| 826 |
log_error("semop(unlock read) error %d\n", errno); |
log_error("semop(unlock read) error %d", errno); |
| 827 |
} |
} |
| 828 |
#else |
#else |
| 829 |
if (sem_wait(&(p_user_list_pool->sem)) == -1) |
if (sem_wait(&(p_user_list_pool->sem)) == -1) |
| 830 |
{ |
{ |
| 831 |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
| 832 |
{ |
{ |
| 833 |
log_error("sem_wait() error %d\n", errno); |
log_error("sem_wait() error %d", errno); |
| 834 |
} |
} |
| 835 |
return -1; |
return -1; |
| 836 |
} |
} |
| 841 |
} |
} |
| 842 |
else |
else |
| 843 |
{ |
{ |
| 844 |
log_error("read_lock_count already 0\n"); |
log_error("read_lock_count already 0"); |
| 845 |
} |
} |
| 846 |
|
|
| 847 |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
| 848 |
{ |
{ |
| 849 |
log_error("sem_post() error %d\n", errno); |
log_error("sem_post() error %d", errno); |
| 850 |
return -1; |
return -1; |
| 851 |
} |
} |
| 852 |
#endif |
#endif |
| 863 |
|
|
| 864 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 865 |
{ |
{ |
| 866 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 867 |
return -1; |
return -1; |
| 868 |
} |
} |
| 869 |
|
|
| 875 |
ret = semop(p_user_list_pool->semid, sops, 1); |
ret = semop(p_user_list_pool->semid, sops, 1); |
| 876 |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
| 877 |
{ |
{ |
| 878 |
log_error("semop(unlock write) error %d\n", errno); |
log_error("semop(unlock write) error %d", errno); |
| 879 |
} |
} |
| 880 |
#else |
#else |
| 881 |
if (sem_wait(&(p_user_list_pool->sem)) == -1) |
if (sem_wait(&(p_user_list_pool->sem)) == -1) |
| 882 |
{ |
{ |
| 883 |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
if (errno != ETIMEDOUT && errno != EAGAIN && errno != EINTR) |
| 884 |
{ |
{ |
| 885 |
log_error("sem_wait() error %d\n", errno); |
log_error("sem_wait() error %d", errno); |
| 886 |
} |
} |
| 887 |
return -1; |
return -1; |
| 888 |
} |
} |
| 893 |
} |
} |
| 894 |
else |
else |
| 895 |
{ |
{ |
| 896 |
log_error("write_lock_count already 0\n"); |
log_error("write_lock_count already 0"); |
| 897 |
} |
} |
| 898 |
|
|
| 899 |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
if (sem_post(&(p_user_list_pool->sem)) == -1) |
| 900 |
{ |
{ |
| 901 |
log_error("sem_post() error %d\n", errno); |
log_error("sem_post() error %d", errno); |
| 902 |
return -1; |
return -1; |
| 903 |
} |
} |
| 904 |
#endif |
#endif |
| 914 |
|
|
| 915 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 916 |
{ |
{ |
| 917 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 918 |
return -1; |
return -1; |
| 919 |
} |
} |
| 920 |
|
|
| 930 |
timer++; |
timer++; |
| 931 |
if (timer % USER_LIST_TRY_LOCK_TIMES == 0) |
if (timer % USER_LIST_TRY_LOCK_TIMES == 0) |
| 932 |
{ |
{ |
| 933 |
log_error("user_list_try_rd_lock() tried %d times\n", timer); |
log_error("user_list_try_rd_lock() tried %d times", timer); |
| 934 |
|
|
| 935 |
if (time(NULL) - tm_first_failure >= USER_LIST_DEAD_LOCK_TIMEOUT) |
if (time(NULL) - tm_first_failure >= USER_LIST_DEAD_LOCK_TIMEOUT) |
| 936 |
{ |
{ |
| 937 |
log_error("Unable to acquire rw_lock for %d seconds\n", time(NULL) - tm_first_failure); |
log_error("Unable to acquire rw_lock for %d seconds", time(NULL) - tm_first_failure); |
| 938 |
#ifndef HAVE_SYSTEM_V |
#ifndef HAVE_SYSTEM_V |
| 939 |
user_list_reset_lock(); |
user_list_reset_lock(); |
| 940 |
log_error("Reset POSIX semaphore to resolve dead lock\n"); |
log_error("Reset POSIX semaphore to resolve dead lock"); |
| 941 |
#endif |
#endif |
| 942 |
break; |
break; |
| 943 |
} |
} |
| 946 |
} |
} |
| 947 |
else // failed |
else // failed |
| 948 |
{ |
{ |
| 949 |
log_error("user_list_try_rd_lock() failed\n"); |
log_error("user_list_try_rd_lock() failed"); |
| 950 |
break; |
break; |
| 951 |
} |
} |
| 952 |
} |
} |
| 962 |
|
|
| 963 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 964 |
{ |
{ |
| 965 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 966 |
return -1; |
return -1; |
| 967 |
} |
} |
| 968 |
|
|
| 978 |
timer++; |
timer++; |
| 979 |
if (timer % USER_LIST_TRY_LOCK_TIMES == 0) |
if (timer % USER_LIST_TRY_LOCK_TIMES == 0) |
| 980 |
{ |
{ |
| 981 |
log_error("user_list_try_rw_lock() tried %d times\n", timer); |
log_error("user_list_try_rw_lock() tried %d times", timer); |
| 982 |
|
|
| 983 |
if (time(NULL) - tm_first_failure >= USER_LIST_DEAD_LOCK_TIMEOUT) |
if (time(NULL) - tm_first_failure >= USER_LIST_DEAD_LOCK_TIMEOUT) |
| 984 |
{ |
{ |
| 985 |
log_error("Unable to acquire rw_lock for %d seconds\n", time(NULL) - tm_first_failure); |
log_error("Unable to acquire rw_lock for %d seconds", time(NULL) - tm_first_failure); |
| 986 |
#ifndef HAVE_SYSTEM_V |
#ifndef HAVE_SYSTEM_V |
| 987 |
user_list_reset_lock(); |
user_list_reset_lock(); |
| 988 |
log_error("Reset POSIX semaphore to resolve dead lock\n"); |
log_error("Reset POSIX semaphore to resolve dead lock"); |
| 989 |
#endif |
#endif |
| 990 |
break; |
break; |
| 991 |
} |
} |
| 994 |
} |
} |
| 995 |
else // failed |
else // failed |
| 996 |
{ |
{ |
| 997 |
log_error("user_list_try_rw_lock() failed\n"); |
log_error("user_list_try_rw_lock() failed"); |
| 998 |
break; |
break; |
| 999 |
} |
} |
| 1000 |
} |
} |
| 1007 |
{ |
{ |
| 1008 |
if (p_user_list_pool == NULL) |
if (p_user_list_pool == NULL) |
| 1009 |
{ |
{ |
| 1010 |
log_error("p_user_list_pool not initialized\n"); |
log_error("p_user_list_pool not initialized"); |
| 1011 |
return -1; |
return -1; |
| 1012 |
} |
} |
| 1013 |
|
|
| 1014 |
if (sem_destroy(&(p_user_list_pool->sem)) == -1) |
if (sem_destroy(&(p_user_list_pool->sem)) == -1) |
| 1015 |
{ |
{ |
| 1016 |
log_error("sem_destroy() error (%d)\n", errno); |
log_error("sem_destroy() error (%d)", errno); |
| 1017 |
} |
} |
| 1018 |
|
|
| 1019 |
p_user_list_pool->read_lock_count = 0; |
p_user_list_pool->read_lock_count = 0; |
| 1021 |
|
|
| 1022 |
if (sem_init(&(p_user_list_pool->sem), 1, 1) == -1) |
if (sem_init(&(p_user_list_pool->sem), 1, 1) == -1) |
| 1023 |
{ |
{ |
| 1024 |
log_error("sem_init() error (%d)\n", errno); |
log_error("sem_init() error (%d)", errno); |
| 1025 |
} |
} |
| 1026 |
|
|
| 1027 |
return 0; |
return 0; |
| 1034 |
|
|
| 1035 |
if (p_users == NULL || p_user_count == NULL || p_page_count == NULL) |
if (p_users == NULL || p_user_count == NULL || p_page_count == NULL) |
| 1036 |
{ |
{ |
| 1037 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1038 |
return -1; |
return -1; |
| 1039 |
} |
} |
| 1040 |
|
|
| 1044 |
// acquire lock of user list |
// acquire lock of user list |
| 1045 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1046 |
{ |
{ |
| 1047 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1048 |
return -2; |
return -2; |
| 1049 |
} |
} |
| 1050 |
|
|
| 1060 |
|
|
| 1061 |
if (page_id < 0 || page_id >= *p_page_count) |
if (page_id < 0 || page_id >= *p_page_count) |
| 1062 |
{ |
{ |
| 1063 |
log_error("Invalid page_id = %d, not in range [0, %d)\n", page_id, *p_page_count); |
log_error("Invalid page_id = %d, not in range [0, %d)", page_id, *p_page_count); |
| 1064 |
ret = -3; |
ret = -3; |
| 1065 |
goto cleanup; |
goto cleanup; |
| 1066 |
} |
} |
| 1077 |
// release lock of user list |
// release lock of user list |
| 1078 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1079 |
{ |
{ |
| 1080 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1081 |
ret = -1; |
ret = -1; |
| 1082 |
} |
} |
| 1083 |
|
|
| 1090 |
|
|
| 1091 |
if (p_online_users == NULL || p_user_count == NULL || p_page_count == NULL) |
if (p_online_users == NULL || p_user_count == NULL || p_page_count == NULL) |
| 1092 |
{ |
{ |
| 1093 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1094 |
return -1; |
return -1; |
| 1095 |
} |
} |
| 1096 |
|
|
| 1100 |
// acquire lock of user list |
// acquire lock of user list |
| 1101 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1102 |
{ |
{ |
| 1103 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1104 |
return -2; |
return -2; |
| 1105 |
} |
} |
| 1106 |
|
|
| 1115 |
|
|
| 1116 |
if (page_id < 0 || page_id >= *p_page_count) |
if (page_id < 0 || page_id >= *p_page_count) |
| 1117 |
{ |
{ |
| 1118 |
log_error("Invalid page_id = %d, not in range [0, %d)\n", page_id, *p_page_count); |
log_error("Invalid page_id = %d, not in range [0, %d)", page_id, *p_page_count); |
| 1119 |
ret = -3; |
ret = -3; |
| 1120 |
goto cleanup; |
goto cleanup; |
| 1121 |
} |
} |
| 1132 |
// release lock of user list |
// release lock of user list |
| 1133 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1134 |
{ |
{ |
| 1135 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1136 |
ret = -1; |
ret = -1; |
| 1137 |
} |
} |
| 1138 |
|
|
| 1143 |
{ |
{ |
| 1144 |
if (p_user_cnt == NULL) |
if (p_user_cnt == NULL) |
| 1145 |
{ |
{ |
| 1146 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1147 |
return -1; |
return -1; |
| 1148 |
} |
} |
| 1149 |
|
|
| 1150 |
// acquire lock of user list |
// acquire lock of user list |
| 1151 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1152 |
{ |
{ |
| 1153 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1154 |
return -2; |
return -2; |
| 1155 |
} |
} |
| 1156 |
|
|
| 1159 |
// release lock of user list |
// release lock of user list |
| 1160 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1161 |
{ |
{ |
| 1162 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1163 |
return -2; |
return -2; |
| 1164 |
} |
} |
| 1165 |
|
|
| 1170 |
{ |
{ |
| 1171 |
if (p_user_cnt == NULL || p_guest_cnt == NULL) |
if (p_user_cnt == NULL || p_guest_cnt == NULL) |
| 1172 |
{ |
{ |
| 1173 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1174 |
return -1; |
return -1; |
| 1175 |
} |
} |
| 1176 |
|
|
| 1177 |
// acquire lock of user list |
// acquire lock of user list |
| 1178 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1179 |
{ |
{ |
| 1180 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1181 |
return -2; |
return -2; |
| 1182 |
} |
} |
| 1183 |
|
|
| 1187 |
// release lock of user list |
// release lock of user list |
| 1188 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1189 |
{ |
{ |
| 1190 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1191 |
return -2; |
return -2; |
| 1192 |
} |
} |
| 1193 |
|
|
| 1198 |
{ |
{ |
| 1199 |
if (p_login_cnt == NULL) |
if (p_login_cnt == NULL) |
| 1200 |
{ |
{ |
| 1201 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1202 |
return -1; |
return -1; |
| 1203 |
} |
} |
| 1204 |
|
|
| 1213 |
|
|
| 1214 |
if (p_user == NULL) |
if (p_user == NULL) |
| 1215 |
{ |
{ |
| 1216 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1217 |
return -1; |
return -1; |
| 1218 |
} |
} |
| 1219 |
|
|
| 1220 |
// acquire lock of user list |
// acquire lock of user list |
| 1221 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1222 |
{ |
{ |
| 1223 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1224 |
return -2; |
return -2; |
| 1225 |
} |
} |
| 1226 |
|
|
| 1233 |
// release lock of user list |
// release lock of user list |
| 1234 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1235 |
{ |
{ |
| 1236 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1237 |
ret = -1; |
ret = -1; |
| 1238 |
} |
} |
| 1239 |
|
|
| 1250 |
|
|
| 1251 |
if (p_user == NULL) |
if (p_user == NULL) |
| 1252 |
{ |
{ |
| 1253 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1254 |
return -1; |
return -1; |
| 1255 |
} |
} |
| 1256 |
|
|
| 1257 |
// acquire lock of user list |
// acquire lock of user list |
| 1258 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1259 |
{ |
{ |
| 1260 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1261 |
return -2; |
return -2; |
| 1262 |
} |
} |
| 1263 |
|
|
| 1299 |
// release lock of user list |
// release lock of user list |
| 1300 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1301 |
{ |
{ |
| 1302 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1303 |
ret = -1; |
ret = -1; |
| 1304 |
} |
} |
| 1305 |
|
|
| 1320 |
|
|
| 1321 |
if (username_prefix == NULL || uid_list == NULL || username_list == NULL) |
if (username_prefix == NULL || uid_list == NULL || username_list == NULL) |
| 1322 |
{ |
{ |
| 1323 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1324 |
return -1; |
return -1; |
| 1325 |
} |
} |
| 1326 |
|
|
| 1329 |
// acquire lock of user list |
// acquire lock of user list |
| 1330 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1331 |
{ |
{ |
| 1332 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1333 |
return -2; |
return -2; |
| 1334 |
} |
} |
| 1335 |
|
|
| 1357 |
|
|
| 1358 |
if (strncasecmp(username_prefix, p_user_list_pool->user_list[p_user_list_pool->user_list_index_current].users[left].username, prefix_len) == 0) // Found |
if (strncasecmp(username_prefix, p_user_list_pool->user_list[p_user_list_pool->user_list_index_current].users[left].username, prefix_len) == 0) // Found |
| 1359 |
{ |
{ |
| 1360 |
log_debug("Debug: match found, pos=%d\n", left); |
log_debug("Debug: match found, pos=%d", left); |
| 1361 |
|
|
| 1362 |
left_save = left; |
left_save = left; |
| 1363 |
right = left; |
right = left; |
| 1383 |
} |
} |
| 1384 |
} |
} |
| 1385 |
|
|
| 1386 |
log_debug("Debug: first match found, pos=%d\n", right); |
log_debug("Debug: first match found, pos=%d", right); |
| 1387 |
|
|
| 1388 |
left = left_save; |
left = left_save; |
| 1389 |
left_save = right; |
left_save = right; |
| 1409 |
} |
} |
| 1410 |
} |
} |
| 1411 |
|
|
| 1412 |
log_debug("Debug: last match found, pos=%d\n", left); |
log_debug("Debug: last match found, pos=%d", left); |
| 1413 |
|
|
| 1414 |
right = left; |
right = left; |
| 1415 |
left = left_save; |
left = left_save; |
| 1427 |
// release lock of user list |
// release lock of user list |
| 1428 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1429 |
{ |
{ |
| 1430 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1431 |
ret = -1; |
ret = -1; |
| 1432 |
} |
} |
| 1433 |
|
|
| 1440 |
|
|
| 1441 |
if (p_user == NULL) |
if (p_user == NULL) |
| 1442 |
{ |
{ |
| 1443 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1444 |
return -1; |
return -1; |
| 1445 |
} |
} |
| 1446 |
|
|
| 1447 |
// acquire lock of user list |
// acquire lock of user list |
| 1448 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1449 |
{ |
{ |
| 1450 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1451 |
return -2; |
return -2; |
| 1452 |
} |
} |
| 1453 |
|
|
| 1460 |
// release lock of user list |
// release lock of user list |
| 1461 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1462 |
{ |
{ |
| 1463 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1464 |
ret = -1; |
ret = -1; |
| 1465 |
} |
} |
| 1466 |
|
|
| 1479 |
|
|
| 1480 |
if (p_users == NULL || p_user_cnt == NULL) |
if (p_users == NULL || p_user_cnt == NULL) |
| 1481 |
{ |
{ |
| 1482 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1483 |
return -1; |
return -1; |
| 1484 |
} |
} |
| 1485 |
|
|
| 1489 |
// acquire lock of user list |
// acquire lock of user list |
| 1490 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1491 |
{ |
{ |
| 1492 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1493 |
return -2; |
return -2; |
| 1494 |
} |
} |
| 1495 |
|
|
| 1551 |
// release lock of user list |
// release lock of user list |
| 1552 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1553 |
{ |
{ |
| 1554 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1555 |
ret = -1; |
ret = -1; |
| 1556 |
} |
} |
| 1557 |
|
|
| 1568 |
|
|
| 1569 |
if (p_uid_list == NULL || p_user_cnt == NULL) |
if (p_uid_list == NULL || p_user_cnt == NULL) |
| 1570 |
{ |
{ |
| 1571 |
log_error("NULL pointer error\n"); |
log_error("NULL pointer error"); |
| 1572 |
return -1; |
return -1; |
| 1573 |
} |
} |
| 1574 |
|
|
| 1575 |
// acquire lock of user list |
// acquire lock of user list |
| 1576 |
if (user_list_rd_lock() < 0) |
if (user_list_rd_lock() < 0) |
| 1577 |
{ |
{ |
| 1578 |
log_error("user_list_rd_lock() error\n"); |
log_error("user_list_rd_lock() error"); |
| 1579 |
return -2; |
return -2; |
| 1580 |
} |
} |
| 1581 |
|
|
| 1609 |
// release lock of user list |
// release lock of user list |
| 1610 |
if (user_list_rd_unlock() < 0) |
if (user_list_rd_unlock() < 0) |
| 1611 |
{ |
{ |
| 1612 |
log_error("user_list_rd_unlock() error\n"); |
log_error("user_list_rd_unlock() error"); |
| 1613 |
ret = -1; |
ret = -1; |
| 1614 |
} |
} |
| 1615 |
|
|
| 1634 |
ret = user_stat_get(&(p_user_list_pool->user_stat_map), uid, &p_stat); |
ret = user_stat_get(&(p_user_list_pool->user_stat_map), uid, &p_stat); |
| 1635 |
if (ret < 0) |
if (ret < 0) |
| 1636 |
{ |
{ |
| 1637 |
log_error("user_stat_get(uid=%d) error: %d\n", uid, ret); |
log_error("user_stat_get(uid=%d) error: %d", uid, ret); |
| 1638 |
return -1; |
return -1; |
| 1639 |
} |
} |
| 1640 |
else if (ret == 0) // user not found |
else if (ret == 0) // user not found |