Fix issues with premature socket closing
parent
99b4c6cf88
commit
b8b244679f
|
@ -233,6 +233,12 @@ enum socket_result get_all_remote_parts(int socket_fd, enum socket_type type, st
|
|||
}
|
||||
write_offset = current_result_size;
|
||||
}
|
||||
// If we never got a blank line, the message never finished.
|
||||
if (!have_blank_line) {
|
||||
free(buffer);
|
||||
free(result);
|
||||
return RESULT_MALFORMED;
|
||||
}
|
||||
struct socket_read_info read_info = get_read_info(message->headers);
|
||||
char *body_result;
|
||||
if (read_info.strategy == STRATEGY_UNDEFINED) {
|
||||
|
|
|
@ -13,7 +13,12 @@
|
|||
bool running = true;
|
||||
|
||||
void handle_signal(int signal) {
|
||||
running = false;
|
||||
if (signal == SIGPIPE) {
|
||||
return;
|
||||
}
|
||||
if (signal == SIGINT || signal == SIGTERM) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
@ -30,6 +35,7 @@ int main(int argc, char* argv[]) {
|
|||
sigemptyset(&sa.sa_mask);
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
sigaction(SIGPIPE, &sa, NULL);
|
||||
|
||||
struct server_info info = setup(port_num);
|
||||
if (info.status == STATUS_ERROR) {
|
||||
|
|
Loading…
Reference in New Issue