ffserver: factor out connection closing from handler

Signed-off-by: 's avatarReynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>
parent 5df2a502
...@@ -1003,9 +1003,7 @@ static int handle_connection(HTTPContext *c) ...@@ -1003,9 +1003,7 @@ static int handle_connection(HTTPContext *c)
if (len < 0) { if (len < 0) {
if (ff_neterrno() != AVERROR(EAGAIN) && if (ff_neterrno() != AVERROR(EAGAIN) &&
ff_neterrno() != AVERROR(EINTR)) { ff_neterrno() != AVERROR(EINTR)) {
/* error : close connection */ goto close_connection;
av_freep(&c->pb_buffer);
return -1;
} }
} else { } else {
c->buffer_ptr += len; c->buffer_ptr += len;
...@@ -1063,10 +1061,8 @@ static int handle_connection(HTTPContext *c) ...@@ -1063,10 +1061,8 @@ static int handle_connection(HTTPContext *c)
break; break;
case RTSPSTATE_SEND_REPLY: case RTSPSTATE_SEND_REPLY:
if (c->poll_entry->revents & (POLLERR | POLLHUP)) { if (c->poll_entry->revents & (POLLERR | POLLHUP))
av_freep(&c->pb_buffer); goto close_connection;
return -1;
}
/* no need to write if no events */ /* no need to write if no events */
if (!(c->poll_entry->revents & POLLOUT)) if (!(c->poll_entry->revents & POLLOUT))
return 0; return 0;
...@@ -1074,9 +1070,7 @@ static int handle_connection(HTTPContext *c) ...@@ -1074,9 +1070,7 @@ static int handle_connection(HTTPContext *c)
if (len < 0) { if (len < 0) {
if (ff_neterrno() != AVERROR(EAGAIN) && if (ff_neterrno() != AVERROR(EAGAIN) &&
ff_neterrno() != AVERROR(EINTR)) { ff_neterrno() != AVERROR(EINTR)) {
/* error : close connection */ goto close_connection;
av_freep(&c->pb_buffer);
return -1;
} }
} else { } else {
c->buffer_ptr += len; c->buffer_ptr += len;
...@@ -1121,6 +1115,10 @@ static int handle_connection(HTTPContext *c) ...@@ -1121,6 +1115,10 @@ static int handle_connection(HTTPContext *c)
return -1; return -1;
} }
return 0; return 0;
close_connection:
av_freep(&c->pb_buffer);
return -1;
} }
static int extract_rates(char *rates, int ratelen, const char *request) static int extract_rates(char *rates, int ratelen, const char *request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment