| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
|
#define _POSIX_C_SOURCE 200809L |
|
|
|
|
| 17 |
#include "bbs.h" |
#include "bbs.h" |
| 18 |
#include "common.h" |
#include "common.h" |
| 19 |
#include "log.h" |
#include "log.h" |
| 20 |
#include "io.h" |
#include "io.h" |
| 21 |
#include "screen.h" |
#include "screen.h" |
| 22 |
#include "menu.h" |
#include "menu.h" |
| 23 |
|
#include "login.h" |
| 24 |
#include <stdio.h> |
#include <stdio.h> |
| 25 |
#include <stdarg.h> |
#include <stdarg.h> |
| 26 |
#include <errno.h> |
#include <errno.h> |
| 407 |
goto cleanup; |
goto cleanup; |
| 408 |
} |
} |
| 409 |
|
|
| 410 |
BBS_last_access_tm = t_used = time(0); |
BBS_last_access_tm = t_used = time(NULL); |
| 411 |
loop = 1; |
loop = 1; |
| 412 |
|
|
| 413 |
while (loop && !SYS_server_exit) |
while (loop && !SYS_server_exit) |
| 432 |
} |
} |
| 433 |
else if (nfds == 0) // timeout |
else if (nfds == 0) // timeout |
| 434 |
{ |
{ |
| 435 |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 436 |
{ |
{ |
| 437 |
break; |
break; |
| 438 |
} |
} |
| 499 |
else |
else |
| 500 |
{ |
{ |
| 501 |
input_buf_len += ret; |
input_buf_len += ret; |
| 502 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 503 |
continue; |
continue; |
| 504 |
} |
} |
| 505 |
} |
} |
| 576 |
} |
} |
| 577 |
else if (ret == 0) // broken pipe |
else if (ret == 0) // broken pipe |
| 578 |
{ |
{ |
| 579 |
log_common("read(socket) EOF\n"); |
#ifdef _DEBUG |
| 580 |
|
log_error("read(socket) EOF\n"); |
| 581 |
|
#endif |
| 582 |
sock_read_wait = 0; |
sock_read_wait = 0; |
| 583 |
loop = 0; |
loop = 0; |
| 584 |
break; |
break; |
| 630 |
} |
} |
| 631 |
else if (ret == 0) // broken pipe |
else if (ret == 0) // broken pipe |
| 632 |
{ |
{ |
| 633 |
log_common("write(STDOUT) EOF\n"); |
#ifdef _DEBUG |
| 634 |
|
log_error("write(STDOUT) EOF\n"); |
| 635 |
|
#endif |
| 636 |
stdout_write_wait = 0; |
stdout_write_wait = 0; |
| 637 |
loop = 0; |
loop = 0; |
| 638 |
break; |
break; |
| 671 |
log_error("Close socket failed\n"); |
log_error("Close socket failed\n"); |
| 672 |
} |
} |
| 673 |
|
|
| 674 |
t_used = time(0) - t_used; |
t_used = time(NULL) - t_used; |
| 675 |
tm_used = gmtime(&t_used); |
tm_used = gmtime(&t_used); |
| 676 |
|
|
| 677 |
log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n", |
log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n", |
| 737 |
|
|
| 738 |
load_bbsnet_conf(CONF_BBSNET); |
load_bbsnet_conf(CONF_BBSNET); |
| 739 |
|
|
| 740 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 741 |
|
|
| 742 |
clearscr(); |
clearscr(); |
| 743 |
bbsnet_refresh(); |
bbsnet_refresh(); |
| 747 |
while (!SYS_server_exit) |
while (!SYS_server_exit) |
| 748 |
{ |
{ |
| 749 |
ch = igetch(100); |
ch = igetch(100); |
| 750 |
|
|
| 751 |
|
if (user_online_update("BBS_NET") < 0) |
| 752 |
|
{ |
| 753 |
|
log_error("user_online_update(BBS_NET) error\n"); |
| 754 |
|
} |
| 755 |
|
|
| 756 |
switch (ch) |
switch (ch) |
| 757 |
{ |
{ |
| 758 |
case KEY_NULL: // broken pipe |
case KEY_NULL: // broken pipe |
| 760 |
case Ctrl('C'): // user cancel |
case Ctrl('C'): // user cancel |
| 761 |
goto cleanup; |
goto cleanup; |
| 762 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 763 |
if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 764 |
{ |
{ |
| 765 |
goto cleanup; |
goto cleanup; |
| 766 |
} |
} |
| 809 |
bbsnet_selchange(); |
bbsnet_selchange(); |
| 810 |
break; |
break; |
| 811 |
} |
} |
| 812 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 813 |
} |
} |
| 814 |
|
|
| 815 |
cleanup: |
cleanup: |