diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-01-08 23:38:56 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-01-08 23:47:29 +0300 |
commit | 295a4884c7fb4c769c73e8013bd6e47803927703 (patch) | |
tree | 970bacd60d595621bc541d8b1a6e12d7f618e437 /src/microhttpd/daemon.c | |
parent | eee0b9ad40d13311b989cfc9995df53fba960d94 (diff) | |
download | libmicrohttpd-295a4884c7fb4c769c73e8013bd6e47803927703.tar.gz libmicrohttpd-295a4884c7fb4c769c73e8013bd6e47803927703.zip |
thread_main_connection_upgrade(): process data from TLS buffers
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 1e94f218..a6edd787 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1289,11 +1289,23 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1289 | break; | 1289 | break; |
1290 | } | 1290 | } |
1291 | if (MHD_INVALID_SOCKET != max_fd) | 1291 | if (MHD_INVALID_SOCKET != max_fd) |
1292 | num_ready = MHD_SYS_select_ (max_fd + 1, | 1292 | { |
1293 | &rs, | 1293 | struct timeval* tvp; |
1294 | &ws, | 1294 | struct timeval tv; |
1295 | NULL, | 1295 | if (con->tls_read_ready) |
1296 | NULL); | 1296 | { /* No need to wait if incoming data is already pending in TLS buffers. */ |
1297 | tv.tv_sec = 0; | ||
1298 | tv.tv_usec = 0; | ||
1299 | tvp = &tv; | ||
1300 | } | ||
1301 | else | ||
1302 | tvp = NULL; | ||
1303 | num_ready = MHD_SYS_select_ (max_fd + 1, | ||
1304 | &rs, | ||
1305 | &ws, | ||
1306 | NULL, | ||
1307 | tvp); | ||
1308 | } | ||
1297 | else | 1309 | else |
1298 | num_ready = 0; | 1310 | num_ready = 0; |
1299 | if (num_ready < 0) | 1311 | if (num_ready < 0) |
@@ -1325,12 +1337,12 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1325 | else if (0 != (daemon->options & MHD_USE_TLS)) | 1337 | else if (0 != (daemon->options & MHD_USE_TLS)) |
1326 | { | 1338 | { |
1327 | /* use poll() */ | 1339 | /* use poll() */ |
1328 | const unsigned int timeout = UINT_MAX; | ||
1329 | 1340 | ||
1330 | while ( (MHD_CONNECTION_UPGRADE == con->state) || | 1341 | while ( (MHD_CONNECTION_UPGRADE == con->state) || |
1331 | (0 != urh->out_buffer_used) ) | 1342 | (0 != urh->out_buffer_used) ) |
1332 | { | 1343 | { |
1333 | struct pollfd p[2]; | 1344 | struct pollfd p[2]; |
1345 | unsigned int timeout; | ||
1334 | 1346 | ||
1335 | memset (p, | 1347 | memset (p, |
1336 | 0, | 1348 | 0, |
@@ -1346,6 +1358,11 @@ thread_main_connection_upgrade (struct MHD_Connection *con) | |||
1346 | if (0 != urh->in_buffer_used) | 1358 | if (0 != urh->in_buffer_used) |
1347 | p[1].events |= POLLOUT; | 1359 | p[1].events |= POLLOUT; |
1348 | 1360 | ||
1361 | if (con->tls_read_ready) | ||
1362 | timeout = 0; /* No need to wait if incoming data is already pending in TLS buffers. */ | ||
1363 | else | ||
1364 | timeout = UINT_MAX; | ||
1365 | |||
1349 | if ( (0 != (p[0].events | p[1].events)) && | 1366 | if ( (0 != (p[0].events | p[1].events)) && |
1350 | (MHD_sys_poll_ (p, | 1367 | (MHD_sys_poll_ (p, |
1351 | 2, | 1368 | 2, |