Show correct message ("Remote end closed connection") when we get EOF

on a socket.

I also added a wrapper function around strerror() for dgets_errno, since
we did the same thing in a few places.  This all needs to be cleaned up
a little - the -1 value we use could in theory clash with an actual
errno error number.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@104 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2010-09-30 13:26:06 +00:00
parent 7a59da1f2e
commit d1e13bc526
5 changed files with 22 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2c01] [Changes 1.2c01]
* Show correct message when a socket connection is closed cleanly. (caf)
* Add /FSET WHOIS_CALLERID for +g mode notification on hybrid & ratbox. (caf) * Add /FSET WHOIS_CALLERID for +g mode notification on hybrid & ratbox. (caf)
* Build script fix to allow plugins to build on x86-64. (caf) * Build script fix to allow plugins to build on x86-64. (caf)

View File

@@ -12,6 +12,7 @@
extern int dgets_errno; extern int dgets_errno;
const char *dgets_strerror(int);
int BX_dgets (char *, int, int, int, void *); int BX_dgets (char *, int, int, int, void *);
int new_select (fd_set *, fd_set *, struct timeval *); int new_select (fd_set *, fd_set *, struct timeval *);
int BX_new_open (int); int BX_new_open (int);

View File

@@ -818,7 +818,7 @@ SocketList *sl;
{ {
case -1: case -1:
{ {
char *real_tmp = ((dgets_errno == -1) ? "Remote End Closed Connection" : strerror(dgets_errno)); const char *real_tmp = dgets_strerror(dgets_errno);
if (do_hook(DCC_LOST_LIST, "%s %s %s", nick, dcc_types[type]->name, real_tmp)) if (do_hook(DCC_LOST_LIST, "%s %s %s", nick, dcc_types[type]->name, real_tmp))
put_it("%s", convert_output_format(fget_string_var(FORMAT_DCC_ERROR_FSET), put_it("%s", convert_output_format(fget_string_var(FORMAT_DCC_ERROR_FSET),
"%s %s %s %s", update_clock(GET_TIME), "%s %s %s %s", update_clock(GET_TIME),
@@ -952,8 +952,8 @@ SocketList *sl;
{ {
case -1: case -1:
{ {
char *real_tmp = ((dgets_errno == -1) ? "Remote End Closed Connection" : strerror(dgets_errno)); const char *real_tmp = dgets_strerror(dgets_errno);
if (do_hook(DCC_LOST_LIST, "%s %s %s", nick, dcc_types[type]->name, real_tmp)) if (do_hook(DCC_LOST_LIST, "%s %s %s", nick, dcc_types[type]->name, real_tmp))
put_it("%s", convert_output_format(fget_string_var(FORMAT_DCC_ERROR_FSET), put_it("%s", convert_output_format(fget_string_var(FORMAT_DCC_ERROR_FSET),
"%s %s %s %s", update_clock(GET_TIME), "%s %s %s %s", update_clock(GET_TIME),
dcc_types[type]->name, nick, real_tmp)); dcc_types[type]->name, nick, real_tmp));

View File

@@ -100,6 +100,20 @@ void SSL_show_errors(void)
} }
#endif #endif
/* Wrapper around strerror() for dgets_errno.
*/
const char *dgets_strerror(int dgets_errno)
{
switch (dgets_errno)
{
case -1:
return "Remote end closed connection";
default:
return strerror(dgets_errno);
}
}
/* /*
* All new dgets -- no more trap doors! * All new dgets -- no more trap doors!
* *
@@ -204,7 +218,7 @@ int BX_dgets (char *str, int des, int buffer, int buffersize, void *ssl_fd)
else if (!nbytes && ioe->write_pos == 0) else if (!nbytes && ioe->write_pos == 0)
{ {
*str = 0; *str = 0;
dgets_errno = errno; dgets_errno = -1;
return -1; return -1;
} }

View File

@@ -535,7 +535,7 @@ static time_t last_timeout = 0;
/* Try to make sure output goes to the correct window */ /* Try to make sure output goes to the correct window */
if(server_list[i].server_change_refnum > -1) if(server_list[i].server_change_refnum > -1)
set_display_target_by_winref(server_list[i].server_change_refnum); set_display_target_by_winref(server_list[i].server_change_refnum);
say("Connection closed from %s: %s", server_list[i].name, (dgets_errno == -1) ? "Remote end closed connection" : strerror(dgets_errno)); say("Connection closed from %s: %s", server_list[i].name, dgets_strerror(dgets_errno));
server_list[i].reconnecting = 1; server_list[i].reconnecting = 1;
close_server(i, empty_string); close_server(i, empty_string);