Add timeout for accept in HTTP Server (#10375)

This commit is contained in:
Florian Märkl 2018-06-18 01:32:24 +02:00 committed by radare
parent 102eb99ea5
commit c1cdc7a8b6
2 changed files with 7 additions and 1 deletions

View File

@ -466,6 +466,9 @@ static int r_core_rtr_http_run(RCore *core, int launch, const char *path) {
eprintf ("Cannot listen on http.port\n");
return 1;
}
r_socket_block_time (s, 1, 1);
if (launch=='H') {
const char *browser = r_config_get (core->config, "http.browser");
r_sys_cmdf ("%s http://%s:%d/%s &",

View File

@ -559,7 +559,10 @@ R_API RSocket *r_socket_accept(RSocket *s) {
//signal (SIGPIPE, SIG_DFL);
sock->fd = accept (s->fd, (struct sockaddr *)&s->sa, &salen);
if (sock->fd == -1) {
r_sys_perror ("accept");
if (errno != EWOULDBLOCK) {
// not just a timeout
r_sys_perror ("accept");
}
free (sock);
return NULL;
}