diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-03-21 09:56:25 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-03-21 09:56:25 +0000 |
commit | 0bdd8b858f981ee42650459bd12f0f8c0e756d12 (patch) | |
tree | f213fff7f032437be68d1826c111a413135a6e6e /ffserver.c | |
parent | 1a4ab332c6e78c82d23dd5bd3f9ab9f6cae3a2a2 (diff) | |
download | ffmpeg-0bdd8b858f981ee42650459bd12f0f8c0e756d12.tar.gz |
send busy reply if max connections number is exceeded
Originally committed as revision 18103 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffserver.c')
-rw-r--r-- | ffserver.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/ffserver.c b/ffserver.c index baefd78096..39ab5632ef 100644 --- a/ffserver.c +++ b/ffserver.c @@ -700,6 +700,22 @@ static void start_wait_request(HTTPContext *c, int is_rtsp) } } +static void http_send_too_busy_reply(int fd) +{ + char buffer[300]; + int len = snprintf(buffer, sizeof(buffer), + "HTTP/1.0 200 Server too busy\r\n" + "Content-type: text/html\r\n" + "\r\n" + "<html><head><title>Too busy</title></head><body>\r\n" + "<p>The server is too busy to serve your request at this time.</p>\r\n" + "<p>The number of current connections is %d, and this exceeds the limit of %d.</p>\r\n" + "</body></html>\r\n", + nb_connections, nb_max_connections); + send(fd, buffer, len, 0); +} + + static void new_connection(int server_fd, int is_rtsp) { struct sockaddr_in from_addr; @@ -715,10 +731,10 @@ static void new_connection(int server_fd, int is_rtsp) } ff_socket_nonblock(fd, 1); - /* XXX: should output a warning page when coming - close to the connection limit */ - if (nb_connections >= nb_max_connections) + if (nb_connections >= nb_max_connections) { + http_send_too_busy_reply(fd); goto fail; + } /* add a new connection */ c = av_mallocz(sizeof(HTTPContext)); |