/[LeafOK_CVS]/lbbs/src/bbs_net.c
ViewVC logotype

Diff of /lbbs/src/bbs_net.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.93 by sysadm, Thu Dec 18 01:39:32 2025 UTC Revision 1.95 by sysadm, Thu Dec 18 02:56:00 2025 UTC
# Line 817  static int bbsnet_connect(int n) Line 817  static int bbsnet_connect(int n)
817          {          {
818                  if (SSH_v2 && ssh_channel_is_closed(SSH_channel))                  if (SSH_v2 && ssh_channel_is_closed(SSH_channel))
819                  {                  {
820  #ifdef _DEBUG                          log_debug("SSH channel is closed\n");
                         log_error("SSH channel is closed\n");  
 #endif  
821                          loop = 0;                          loop = 0;
822                          break;                          break;
823                  }                  }
824    
825                  if (bbsnet_conf[n].use_ssh && ssh_channel_is_closed(channel))                  if (bbsnet_conf[n].use_ssh && ssh_channel_is_closed(channel))
826                  {                  {
827  #ifdef _DEBUG                          log_debug("Remote SSH channel is closed\n");
                         log_error("Remote SSH channel is closed\n");  
 #endif  
828                          loop = 0;                          loop = 0;
829                          break;                          break;
830                  }                  }
# Line 871  static int bbsnet_connect(int n) Line 867  static int bbsnet_connect(int n)
867                  for (int i = 0; i < nfds; i++)                  for (int i = 0; i < nfds; i++)
868                  {                  {
869  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
870                          if (events[i].data.fd == STDIN_FILENO)                          if (events[i].events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR))
871    #else
872                            if (pfds[i].revents & (POLLRDHUP | POLLHUP | POLLERR))
873    #endif
874                            {
875    #ifdef HAVE_SYS_EPOLL_H
876                                    log_debug("FD (%d) error events (%d)\n", events[i].data.fd, events[i].events);
877    #else
878                                    log_debug("FD (%d) error events (%d)\n", pfds[i].fd, pfds[i].revents);
879    #endif
880                                    loop = 0;
881                                    break;
882                            }
883    
884    #ifdef HAVE_SYS_EPOLL_H
885                            if (events[i].data.fd == STDIN_FILENO && (events[i].events & EPOLLIN))
886  #else  #else
887                          if (pfds[i].fd == STDIN_FILENO && (pfds[i].revents & POLLIN))                          if (pfds[i].fd == STDIN_FILENO && (pfds[i].revents & POLLIN))
888  #endif  #endif
# Line 905  static int bbsnet_connect(int n) Line 916  static int bbsnet_connect(int n)
916                          }                          }
917    
918  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
919                          if (events[i].data.fd == STDOUT_FILENO)                          if (events[i].data.fd == STDOUT_FILENO && (events[i].events & EPOLLOUT))
920  #else  #else
921                          if (pfds[i].fd == STDOUT_FILENO && (pfds[i].revents & POLLOUT))                          if (pfds[i].fd == STDOUT_FILENO && (pfds[i].revents & POLLOUT))
922  #endif  #endif
# Line 923  static int bbsnet_connect(int n) Line 934  static int bbsnet_connect(int n)
934                                          ret = ssh_channel_read_nonblocking(SSH_channel, input_buf + input_buf_len, sizeof(input_buf) - (uint32_t)input_buf_len, 0);                                          ret = ssh_channel_read_nonblocking(SSH_channel, input_buf + input_buf_len, sizeof(input_buf) - (uint32_t)input_buf_len, 0);
935                                          if (ret == SSH_ERROR)                                          if (ret == SSH_ERROR)
936                                          {                                          {
937  #ifdef _DEBUG                                                  log_debug("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(SSH_session));
                                                 log_error("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(SSH_session));  
 #endif  
938                                                  loop = 0;                                                  loop = 0;
939                                                  break;                                                  break;
940                                          }                                          }
# Line 970  static int bbsnet_connect(int n) Line 979  static int bbsnet_connect(int n)
979                                  }                                  }
980                                  else if (ret == 0) // broken pipe                                  else if (ret == 0) // broken pipe
981                                  {                                  {
982  #ifdef _DEBUG                                          log_debug("read(STDIN) EOF\n");
                                         log_error("read(STDIN) EOF\n");  
 #endif  
983                                          stdin_read_wait = 0;                                          stdin_read_wait = 0;
984                                          loop = 0;                                          loop = 0;
985                                          break;                                          break;
# Line 1001  static int bbsnet_connect(int n) Line 1008  static int bbsnet_connect(int n)
1008  #ifdef _DEBUG  #ifdef _DEBUG
1009                                  for (int j = input_buf_offset; j < input_buf_len; j++)                                  for (int j = input_buf_offset; j < input_buf_len; j++)
1010                                  {                                  {
1011                                          log_error("Debug input: <--[%u]\n", (input_buf[j] + 256) % 256);                                          log_debug("input: <--[%u]\n", (input_buf[j] + 256) % 256);
1012                                  }                                  }
1013  #endif  #endif
1014    
# Line 1016  static int bbsnet_connect(int n) Line 1023  static int bbsnet_connect(int n)
1023  #ifdef _DEBUG  #ifdef _DEBUG
1024                                  for (int j = input_conv_offset; j < input_conv_len; j++)                                  for (int j = input_conv_offset; j < input_conv_len; j++)
1025                                  {                                  {
1026                                          log_error("Debug input_conv: <--[%u]\n", (input_conv[j] + 256) % 256);                                          log_debug("input_conv: <--[%u]\n", (input_conv[j] + 256) % 256);
1027                                  }                                  }
1028  #endif  #endif
1029                          }                          }
# Line 1028  static int bbsnet_connect(int n) Line 1035  static int bbsnet_connect(int n)
1035                                          ret = ssh_channel_write(channel, input_conv + input_conv_offset, (uint32_t)(input_conv_len - input_conv_offset));                                          ret = ssh_channel_write(channel, input_conv + input_conv_offset, (uint32_t)(input_conv_len - input_conv_offset));
1036                                          if (ret == SSH_ERROR)                                          if (ret == SSH_ERROR)
1037                                          {                                          {
1038  #ifdef _DEBUG                                                  log_debug("ssh_channel_write() error: %s\n", ssh_get_error(session));
                                                 log_error("ssh_channel_write() error: %s\n", ssh_get_error(session));  
 #endif  
1039                                                  loop = 0;                                                  loop = 0;
1040                                                  break;                                                  break;
1041                                          }                                          }
# Line 1052  static int bbsnet_connect(int n) Line 1057  static int bbsnet_connect(int n)
1057                                          }                                          }
1058                                          else                                          else
1059                                          {                                          {
1060  #ifdef _DEBUG                                                  log_debug("write(socket) error (%d)\n", errno);
                                                 log_error("write(socket) error (%d)\n", errno);  
 #endif  
1061                                                  loop = 0;                                                  loop = 0;
1062                                                  break;                                                  break;
1063                                          }                                          }
1064                                  }                                  }
1065                                  else if (ret == 0) // broken pipe                                  else if (ret == 0) // broken pipe
1066                                  {                                  {
1067  #ifdef _DEBUG                                          log_debug("write(socket) EOF\n");
                                         log_error("write(socket) EOF\n");  
 #endif  
1068                                          sock_write_wait = 0;                                          sock_write_wait = 0;
1069                                          loop = 0;                                          loop = 0;
1070                                          break;                                          break;
# Line 1092  static int bbsnet_connect(int n) Line 1093  static int bbsnet_connect(int n)
1093                                                                                                             (uint32_t)(sizeof(output_buf) - (size_t)output_buf_len), 0);                                                                                                             (uint32_t)(sizeof(output_buf) - (size_t)output_buf_len), 0);
1094                                          if (ret == SSH_ERROR)                                          if (ret == SSH_ERROR)
1095                                          {                                          {
1096  #ifdef _DEBUG                                                  log_debug("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(session));
                                                 log_error("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(session));  
 #endif  
1097                                                  loop = 0;                                                  loop = 0;
1098                                                  break;                                                  break;
1099                                          }                                          }
# Line 1127  static int bbsnet_connect(int n) Line 1126  static int bbsnet_connect(int n)
1126                                          }                                          }
1127                                          else                                          else
1128                                          {                                          {
1129  #ifdef _DEBUG                                                  log_debug("read(socket) error (%d)\n", errno);
                                                 log_error("read(socket) error (%d)\n", errno);  
 #endif  
1130                                                  loop = 0;                                                  loop = 0;
1131                                                  break;                                                  break;
1132                                          }                                          }
1133                                  }                                  }
1134                                  else if (ret == 0) // broken pipe                                  else if (ret == 0) // broken pipe
1135                                  {                                  {
1136  #ifdef _DEBUG                                          log_debug("read(socket) EOF\n");
                                         log_error("read(socket) EOF\n");  
 #endif  
1137                                          sock_read_wait = 0;                                          sock_read_wait = 0;
1138                                          loop = 0;                                          loop = 0;
1139                                          break;                                          break;
# Line 1170  static int bbsnet_connect(int n) Line 1165  static int bbsnet_connect(int n)
1165                                          ret = ssh_channel_write(SSH_channel, output_conv + output_conv_offset, (uint32_t)(output_conv_len - output_conv_offset));                                          ret = ssh_channel_write(SSH_channel, output_conv + output_conv_offset, (uint32_t)(output_conv_len - output_conv_offset));
1166                                          if (ret == SSH_ERROR)                                          if (ret == SSH_ERROR)
1167                                          {                                          {
1168  #ifdef _DEBUG                                                  log_debug("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));
                                                 log_error("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));  
 #endif  
1169                                                  loop = 0;                                                  loop = 0;
1170                                                  break;                                                  break;
1171                                          }                                          }
# Line 1194  static int bbsnet_connect(int n) Line 1187  static int bbsnet_connect(int n)
1187                                          }                                          }
1188                                          else                                          else
1189                                          {                                          {
1190  #ifdef _DEBUG                                                  log_debug("write(STDOUT) error (%d)\n", errno);
                                                 log_error("write(STDOUT) error (%d)\n", errno);  
 #endif  
1191                                                  loop = 0;                                                  loop = 0;
1192                                                  break;                                                  break;
1193                                          }                                          }
1194                                  }                                  }
1195                                  else if (ret == 0) // broken pipe                                  else if (ret == 0) // broken pipe
1196                                  {                                  {
1197  #ifdef _DEBUG                                          log_debug("write(STDOUT) EOF\n");
                                         log_error("write(STDOUT) EOF\n");  
 #endif  
1198                                          stdout_write_wait = 0;                                          stdout_write_wait = 0;
1199                                          loop = 0;                                          loop = 0;
1200                                          break;                                          break;
# Line 1363  int bbs_net() Line 1352  int bbs_net()
1352                  switch (ch)                  switch (ch)
1353                  {                  {
1354                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
1355  #ifdef _DEBUG                          log_debug("KEY_NULL\n");
                         log_error("KEY_NULL\n");  
 #endif  
1356                          goto cleanup;                          goto cleanup;
1357                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
1358                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1