From: sgunderson Date: Tue, 9 Oct 2001 21:33:46 +0000 (+0000) Subject: Fixed a file transfer bug, where the initial "150 Opening connection (...)" message... X-Git-Url: https://git.sesse.net/?p=betaftpd;a=commitdiff_plain;h=0784839517fd6cc301881c98419ba469d2cde04f Fixed a file transfer bug, where the initial "150 Opening connection (...)" message would never be sent in time (again related to numeric fixes). --- diff --git a/ftpd.c b/ftpd.c index 73f1dca..19816bf 100644 --- a/ftpd.c +++ b/ftpd.c @@ -683,12 +683,25 @@ int process_all_sendfiles(fd_set * const active_clients, const int num_ac) f->sock = tempsock; ioctl(f->sock, FIONBIO, &one); init_file_transfer(f); + + flush_numeric(f->owner); + if (f->owner->free_me) { + destroy_conn(f->owner); + continue; + } + #if WANT_UPLOAD if (f->upload) continue; #endif } if (f->state < 5) { init_file_transfer(f); + + flush_numeric(f->owner); + if (f->owner->free_me) { + destroy_conn(f->owner); + continue; + } #if WANT_UPLOAD if (f->upload) continue; #endif @@ -1225,6 +1238,16 @@ void numeric(struct conn * const c, const int numeric, const char * const format va_end(args); } +/* flush_numeric(): + * Actually flushes the buffer written by numeric() -- but does + * NOT erase it. If an error, sets the "free_me" flag in the socket. + */ +void flush_numeric(struct conn * const c) +{ + if (send(c->sock, message_buf, strlen(message_buf), 0) == -1 && errno == EPIPE) + c->free_me = 1; +} + /* * init_file_transfer(): * Initiate a data connection for sending. This does not open diff --git a/ftpd.h b/ftpd.h index 835f4d7..3d11bea 100644 --- a/ftpd.h +++ b/ftpd.h @@ -209,6 +209,7 @@ void time_out_sockets(); void remove_bytes(struct conn * const c, const int i); void numeric(struct conn * const c, const int numeric, const char * const format, ...); +void flush_numeric(struct conn * const c); void init_file_transfer(struct ftran * const f); int create_server_socket();