diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-02-15 04:04:22 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-02-15 04:04:22 +0100 |
commit | 9914072c16b773a828709ecc61062c37c864e858 (patch) | |
tree | b080aad962179ebdfc572077580ca05143a9c8e7 | |
parent | bca7a709f8129e856d9175ea1081abc0feec883c (diff) | |
download | libmicrohttpd-9914072c16b773a828709ecc61062c37c864e858.tar.gz libmicrohttpd-9914072c16b773a828709ecc61062c37c864e858.zip |
add explicit nonnull declarations to function arguments
-rw-r--r-- | src/include/microhttpd2.h | 215 | ||||
-rw-r--r-- | src/lib/daemon_create.c | 2 | ||||
-rw-r--r-- | src/lib/daemon_destroy.c | 2 | ||||
-rw-r--r-- | src/lib/daemon_get_fdset.c | 166 | ||||
-rw-r--r-- | src/lib/internal.h | 215 | ||||
-rw-r--r-- | src/lib/request.c | 4 | ||||
-rw-r--r-- | src/lib/response.c | 5 |
7 files changed, 525 insertions, 84 deletions
diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h index 2fae90b1..2ec39acb 100644 --- a/src/include/microhttpd2.h +++ b/src/include/microhttpd2.h | |||
@@ -267,6 +267,16 @@ typedef SOCKET MHD_socket; | |||
267 | #define _MHD_DEPR_FUNC(msg) | 267 | #define _MHD_DEPR_FUNC(msg) |
268 | #endif /* !_MHD_DEPR_FUNC */ | 268 | #endif /* !_MHD_DEPR_FUNC */ |
269 | 269 | ||
270 | |||
271 | /* Define MHD_NONNULL attribute */ | ||
272 | |||
273 | /** | ||
274 | * Macro to indicate that certain parameters must be | ||
275 | * non-null. Todo: port to non-gcc platforms. | ||
276 | */ | ||
277 | #define MHD_NONNULL(...) __THROW __nonnull((__VA_ARGS__)) | ||
278 | |||
279 | |||
270 | /** | 280 | /** |
271 | * Not all architectures and `printf()`'s support the `long long` type. | 281 | * Not all architectures and `printf()`'s support the `long long` type. |
272 | * This gives the ability to replace `long long` with just a `long`, | 282 | * This gives the ability to replace `long long` with just a `long`, |
@@ -541,6 +551,17 @@ enum MHD_StatusCode | |||
541 | */ | 551 | */ |
542 | MHD_SC_EPOLL_CTL_CONFIGURE_NOINHERIT_FAILED = 50035, | 552 | MHD_SC_EPOLL_CTL_CONFIGURE_NOINHERIT_FAILED = 50035, |
543 | 553 | ||
554 | /** | ||
555 | * We failed to build the FD set because a socket was | ||
556 | * outside of the permitted range. | ||
557 | */ | ||
558 | MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE = 50036, | ||
559 | |||
560 | /** | ||
561 | * This daemon was not configured with options that | ||
562 | * would allow us to build an FD set for select(). | ||
563 | */ | ||
564 | MHD_SC_CONFIGURATION_MISSMATCH_FOR_GET_FDSET = 50037, | ||
544 | 565 | ||
545 | }; | 566 | }; |
546 | 567 | ||
@@ -1148,7 +1169,8 @@ typedef struct MHD_Action * | |||
1148 | */ | 1169 | */ |
1149 | _MHD_EXTERN struct MHD_Daemon * | 1170 | _MHD_EXTERN struct MHD_Daemon * |
1150 | MHD_daemon_create (MHD_RequestCallback cb, | 1171 | MHD_daemon_create (MHD_RequestCallback cb, |
1151 | void *cb_cls); | 1172 | void *cb_cls) |
1173 | MHD_NONNULL(1); | ||
1152 | 1174 | ||
1153 | 1175 | ||
1154 | /** | 1176 | /** |
@@ -1160,7 +1182,8 @@ MHD_daemon_create (MHD_RequestCallback cb, | |||
1160 | * @ingroup event | 1182 | * @ingroup event |
1161 | */ | 1183 | */ |
1162 | _MHD_EXTERN enum MHD_StatusCode | 1184 | _MHD_EXTERN enum MHD_StatusCode |
1163 | MHD_daemon_start (struct MHD_Daemon *daemon); | 1185 | MHD_daemon_start (struct MHD_Daemon *daemon) |
1186 | MHD_NONNULL(1); | ||
1164 | 1187 | ||
1165 | 1188 | ||
1166 | /** | 1189 | /** |
@@ -1184,7 +1207,8 @@ MHD_daemon_start (struct MHD_Daemon *daemon); | |||
1184 | * @ingroup specialized | 1207 | * @ingroup specialized |
1185 | */ | 1208 | */ |
1186 | _MHD_EXTERN MHD_socket | 1209 | _MHD_EXTERN MHD_socket |
1187 | MHD_daemon_quiesce (struct MHD_Daemon *daemon); | 1210 | MHD_daemon_quiesce (struct MHD_Daemon *daemon) |
1211 | MHD_NONNULL(1); | ||
1188 | 1212 | ||
1189 | 1213 | ||
1190 | /** | 1214 | /** |
@@ -1194,7 +1218,8 @@ MHD_daemon_quiesce (struct MHD_Daemon *daemon); | |||
1194 | * @ingroup event | 1218 | * @ingroup event |
1195 | */ | 1219 | */ |
1196 | _MHD_EXTERN void | 1220 | _MHD_EXTERN void |
1197 | MHD_daemon_destroy (struct MHD_Daemon *daemon); | 1221 | MHD_daemon_destroy (struct MHD_Daemon *daemon) |
1222 | MHD_NONNULL(1); | ||
1198 | 1223 | ||
1199 | 1224 | ||
1200 | /** | 1225 | /** |
@@ -1226,7 +1251,8 @@ _MHD_EXTERN enum MHD_StatusCode | |||
1226 | MHD_daemon_add_connection (struct MHD_Daemon *daemon, | 1251 | MHD_daemon_add_connection (struct MHD_Daemon *daemon, |
1227 | MHD_socket client_socket, | 1252 | MHD_socket client_socket, |
1228 | const struct sockaddr *addr, | 1253 | const struct sockaddr *addr, |
1229 | socklen_t addrlen); | 1254 | socklen_t addrlen) |
1255 | MHD_NONNULL(1); | ||
1230 | 1256 | ||
1231 | 1257 | ||
1232 | /** | 1258 | /** |
@@ -1258,7 +1284,8 @@ MHD_daemon_get_fdset (struct MHD_Daemon *daemon, | |||
1258 | fd_set *read_fd_set, | 1284 | fd_set *read_fd_set, |
1259 | fd_set *write_fd_set, | 1285 | fd_set *write_fd_set, |
1260 | fd_set *except_fd_set, | 1286 | fd_set *except_fd_set, |
1261 | MHD_socket *max_fd); | 1287 | MHD_socket *max_fd) |
1288 | MHD_NONNULL(1,2,3,4); | ||
1262 | 1289 | ||
1263 | 1290 | ||
1264 | /** | 1291 | /** |
@@ -1294,7 +1321,8 @@ MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon, | |||
1294 | fd_set *write_fd_set, | 1321 | fd_set *write_fd_set, |
1295 | fd_set *except_fd_set, | 1322 | fd_set *except_fd_set, |
1296 | MHD_socket *max_fd, | 1323 | MHD_socket *max_fd, |
1297 | unsigned int fd_setsize); | 1324 | unsigned int fd_setsize) |
1325 | MHD_NONNULL(1,2,3,4); | ||
1298 | 1326 | ||
1299 | 1327 | ||
1300 | /** | 1328 | /** |
@@ -1344,7 +1372,8 @@ MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon, | |||
1344 | */ | 1372 | */ |
1345 | _MHD_EXTERN enum MHD_StatusCode | 1373 | _MHD_EXTERN enum MHD_StatusCode |
1346 | MHD_daemon_get_timeout (struct MHD_Daemon *daemon, | 1374 | MHD_daemon_get_timeout (struct MHD_Daemon *daemon, |
1347 | MHD_UNSIGNED_LONG_LONG *timeout); | 1375 | MHD_UNSIGNED_LONG_LONG *timeout) |
1376 | MHD_NONNULL(1,2); | ||
1348 | 1377 | ||
1349 | 1378 | ||
1350 | /** | 1379 | /** |
@@ -1366,7 +1395,8 @@ MHD_daemon_get_timeout (struct MHD_Daemon *daemon, | |||
1366 | * @ingroup event | 1395 | * @ingroup event |
1367 | */ | 1396 | */ |
1368 | _MHD_EXTERN enum MHD_StatusCode | 1397 | _MHD_EXTERN enum MHD_StatusCode |
1369 | MHD_daemon_run (struct MHD_Daemon *daemon); | 1398 | MHD_daemon_run (struct MHD_Daemon *daemon) |
1399 | MHD_NONNULL(1); | ||
1370 | 1400 | ||
1371 | 1401 | ||
1372 | /** | 1402 | /** |
@@ -1395,9 +1425,8 @@ _MHD_EXTERN enum MHD_StatusCode | |||
1395 | MHD_daemon_run_from_select (struct MHD_Daemon *daemon, | 1425 | MHD_daemon_run_from_select (struct MHD_Daemon *daemon, |
1396 | const fd_set *read_fd_set, | 1426 | const fd_set *read_fd_set, |
1397 | const fd_set *write_fd_set, | 1427 | const fd_set *write_fd_set, |
1398 | const fd_set *except_fd_set); | 1428 | const fd_set *except_fd_set) |
1399 | 1429 | MHD_NONNULL(1,2,3,4); | |
1400 | |||
1401 | 1430 | ||
1402 | 1431 | ||
1403 | /* ********************* daemon options ************** */ | 1432 | /* ********************* daemon options ************** */ |
@@ -1431,7 +1460,8 @@ typedef void | |||
1431 | _MHD_EXTERN void | 1460 | _MHD_EXTERN void |
1432 | MHD_daemon_set_logger (struct MHD_Daemon *daemon, | 1461 | MHD_daemon_set_logger (struct MHD_Daemon *daemon, |
1433 | MHD_LoggingCallback logger, | 1462 | MHD_LoggingCallback logger, |
1434 | void *logger_cls); | 1463 | void *logger_cls) |
1464 | MHD_NONNULL(1); | ||
1435 | 1465 | ||
1436 | 1466 | ||
1437 | /** | 1467 | /** |
@@ -1448,7 +1478,8 @@ MHD_daemon_set_logger (struct MHD_Daemon *daemon, | |||
1448 | * @param daemon which instance to disable clock for. | 1478 | * @param daemon which instance to disable clock for. |
1449 | */ | 1479 | */ |
1450 | _MHD_EXTERN void | 1480 | _MHD_EXTERN void |
1451 | MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon); | 1481 | MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon) |
1482 | MHD_NONNULL(1); | ||
1452 | 1483 | ||
1453 | 1484 | ||
1454 | /** | 1485 | /** |
@@ -1469,7 +1500,8 @@ MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon); | |||
1469 | * @param daemon which instance to disable itc for | 1500 | * @param daemon which instance to disable itc for |
1470 | */ | 1501 | */ |
1471 | _MHD_EXTERN void | 1502 | _MHD_EXTERN void |
1472 | MHD_daemon_disable_itc (struct MHD_Daemon *daemon); | 1503 | MHD_daemon_disable_itc (struct MHD_Daemon *daemon) |
1504 | MHD_NONNULL(1); | ||
1473 | 1505 | ||
1474 | 1506 | ||
1475 | /** | 1507 | /** |
@@ -1481,7 +1513,8 @@ MHD_daemon_disable_itc (struct MHD_Daemon *daemon); | |||
1481 | * @param daemon which instance to enable turbo for | 1513 | * @param daemon which instance to enable turbo for |
1482 | */ | 1514 | */ |
1483 | _MHD_EXTERN void | 1515 | _MHD_EXTERN void |
1484 | MHD_daemon_enable_turbo (struct MHD_Daemon *daemon); | 1516 | MHD_daemon_enable_turbo (struct MHD_Daemon *daemon) |
1517 | MHD_NONNULL(1); | ||
1485 | 1518 | ||
1486 | 1519 | ||
1487 | /** | 1520 | /** |
@@ -1494,7 +1527,8 @@ MHD_daemon_enable_turbo (struct MHD_Daemon *daemon); | |||
1494 | * @param daemon which instance to disable suspend for | 1527 | * @param daemon which instance to disable suspend for |
1495 | */ | 1528 | */ |
1496 | _MHD_EXTERN void | 1529 | _MHD_EXTERN void |
1497 | MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon); | 1530 | MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon) |
1531 | MHD_NONNULL(1); | ||
1498 | 1532 | ||
1499 | 1533 | ||
1500 | /** | 1534 | /** |
@@ -1509,7 +1543,8 @@ MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon); | |||
1509 | * @param daemon which instance to enable suspend/resume for | 1543 | * @param daemon which instance to enable suspend/resume for |
1510 | */ | 1544 | */ |
1511 | _MHD_EXTERN void | 1545 | _MHD_EXTERN void |
1512 | MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon); | 1546 | MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon) |
1547 | MHD_NONNULL(1); | ||
1513 | 1548 | ||
1514 | 1549 | ||
1515 | /** | 1550 | /** |
@@ -1555,7 +1590,8 @@ enum MHD_FastOpenMethod | |||
1555 | _MHD_EXTERN enum MHD_Bool | 1590 | _MHD_EXTERN enum MHD_Bool |
1556 | MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, | 1591 | MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, |
1557 | enum MHD_FastOpenMethod fom, | 1592 | enum MHD_FastOpenMethod fom, |
1558 | unsigned int queue_length); | 1593 | unsigned int queue_length) |
1594 | MHD_NONNULL(1); | ||
1559 | 1595 | ||
1560 | 1596 | ||
1561 | /** | 1597 | /** |
@@ -1608,7 +1644,8 @@ enum MHD_AddressFamily | |||
1608 | _MHD_EXTERN void | 1644 | _MHD_EXTERN void |
1609 | MHD_daemon_bind_port (struct MHD_Daemon *daemon, | 1645 | MHD_daemon_bind_port (struct MHD_Daemon *daemon, |
1610 | enum MHD_AddressFamily af, | 1646 | enum MHD_AddressFamily af, |
1611 | uint16_t port); | 1647 | uint16_t port) |
1648 | MHD_NONNULL(1); | ||
1612 | 1649 | ||
1613 | 1650 | ||
1614 | /** | 1651 | /** |
@@ -1623,7 +1660,8 @@ MHD_daemon_bind_port (struct MHD_Daemon *daemon, | |||
1623 | _MHD_EXTERN void | 1660 | _MHD_EXTERN void |
1624 | MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, | 1661 | MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, |
1625 | const struct sockaddr *sa, | 1662 | const struct sockaddr *sa, |
1626 | size_t sa_len); | 1663 | size_t sa_len) |
1664 | MHD_NONNULL(1); | ||
1627 | 1665 | ||
1628 | 1666 | ||
1629 | /** | 1667 | /** |
@@ -1635,7 +1673,8 @@ MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, | |||
1635 | */ | 1673 | */ |
1636 | _MHD_EXTERN void | 1674 | _MHD_EXTERN void |
1637 | MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, | 1675 | MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, |
1638 | int listen_backlog); | 1676 | int listen_backlog) |
1677 | MHD_NONNULL(1); | ||
1639 | 1678 | ||
1640 | 1679 | ||
1641 | /** | 1680 | /** |
@@ -1649,7 +1688,8 @@ MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, | |||
1649 | * @param daemon daemon to configure address reuse for | 1688 | * @param daemon daemon to configure address reuse for |
1650 | */ | 1689 | */ |
1651 | _MHD_EXTERN void | 1690 | _MHD_EXTERN void |
1652 | MHD_daemon_listen_allow_address_reuse (struct MHD_Daemon *daemon); | 1691 | MHD_daemon_listen_allow_address_reuse (struct MHD_Daemon *daemon) |
1692 | MHD_NONNULL(1); | ||
1653 | 1693 | ||
1654 | 1694 | ||
1655 | /** | 1695 | /** |
@@ -1668,7 +1708,8 @@ MHD_daemon_listen_allow_address_reuse (struct MHD_Daemon *daemon); | |||
1668 | */ | 1708 | */ |
1669 | _MHD_EXTERN void | 1709 | _MHD_EXTERN void |
1670 | MHD_daemon_listen_socket (struct MHD_Daemon *daemon, | 1710 | MHD_daemon_listen_socket (struct MHD_Daemon *daemon, |
1671 | MHD_socket listen_socket); | 1711 | MHD_socket listen_socket) |
1712 | MHD_NONNULL(1); | ||
1672 | 1713 | ||
1673 | 1714 | ||
1674 | /** | 1715 | /** |
@@ -1708,7 +1749,8 @@ enum MHD_EventLoopSyscall | |||
1708 | */ | 1749 | */ |
1709 | _MHD_EXTERN enum MHD_Bool | 1750 | _MHD_EXTERN enum MHD_Bool |
1710 | MHD_daemon_event_loop (struct MHD_Daemon *daemon, | 1751 | MHD_daemon_event_loop (struct MHD_Daemon *daemon, |
1711 | enum MHD_EventLoopSyscall els); | 1752 | enum MHD_EventLoopSyscall els) |
1753 | MHD_NONNULL(1); | ||
1712 | 1754 | ||
1713 | 1755 | ||
1714 | /** | 1756 | /** |
@@ -1752,7 +1794,8 @@ enum MHD_ProtocolStrictLevel | |||
1752 | */ | 1794 | */ |
1753 | _MHD_EXTERN void | 1795 | _MHD_EXTERN void |
1754 | MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, | 1796 | MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, |
1755 | enum MHD_ProtocolStrictLevel sl); | 1797 | enum MHD_ProtocolStrictLevel sl) |
1798 | MHD_NONNULL(1); | ||
1756 | 1799 | ||
1757 | 1800 | ||
1758 | /** | 1801 | /** |
@@ -1762,7 +1805,8 @@ MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, | |||
1762 | * @param daemon daemon to set SHOUTcast option for | 1805 | * @param daemon daemon to set SHOUTcast option for |
1763 | */ | 1806 | */ |
1764 | _MHD_EXTERN void | 1807 | _MHD_EXTERN void |
1765 | MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon); | 1808 | MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon) |
1809 | MHD_NONNULL(1); | ||
1766 | 1810 | ||
1767 | 1811 | ||
1768 | /** | 1812 | /** |
@@ -1783,7 +1827,8 @@ MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon); | |||
1783 | _MHD_EXTERN enum MHD_StatusCode | 1827 | _MHD_EXTERN enum MHD_StatusCode |
1784 | MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, | 1828 | MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, |
1785 | const char *tls_backend, | 1829 | const char *tls_backend, |
1786 | const char *ciphers); | 1830 | const char *ciphers) |
1831 | MHD_NONNULL(1); | ||
1787 | 1832 | ||
1788 | 1833 | ||
1789 | /** | 1834 | /** |
@@ -1802,7 +1847,8 @@ _MHD_EXTERN enum MHD_StatusCode | |||
1802 | MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, | 1847 | MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, |
1803 | const char *mem_key, | 1848 | const char *mem_key, |
1804 | const char *mem_cert, | 1849 | const char *mem_cert, |
1805 | const char *pass); | 1850 | const char *pass) |
1851 | MHD_NONNULL(1,2,3); | ||
1806 | 1852 | ||
1807 | 1853 | ||
1808 | /** | 1854 | /** |
@@ -1815,7 +1861,8 @@ MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, | |||
1815 | */ | 1861 | */ |
1816 | _MHD_EXTERN enum MHD_StatusCode | 1862 | _MHD_EXTERN enum MHD_StatusCode |
1817 | MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, | 1863 | MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, |
1818 | const char *dh); | 1864 | const char *dh) |
1865 | MHD_NONNULL(1); | ||
1819 | 1866 | ||
1820 | 1867 | ||
1821 | /** | 1868 | /** |
@@ -1828,7 +1875,8 @@ MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, | |||
1828 | */ | 1875 | */ |
1829 | _MHD_EXTERN enum MHD_StatusCode | 1876 | _MHD_EXTERN enum MHD_StatusCode |
1830 | MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, | 1877 | MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, |
1831 | const char *mem_trust); | 1878 | const char *mem_trust) |
1879 | MHD_NONNULL(1); | ||
1832 | 1880 | ||
1833 | 1881 | ||
1834 | /** | 1882 | /** |
@@ -1840,7 +1888,8 @@ MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, | |||
1840 | */ | 1888 | */ |
1841 | _MHD_EXTERN enum MHD_StatusCode | 1889 | _MHD_EXTERN enum MHD_StatusCode |
1842 | MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, | 1890 | MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, |
1843 | int gnutls_credentials); | 1891 | int gnutls_credentials) |
1892 | MHD_NONNULL(1); | ||
1844 | 1893 | ||
1845 | 1894 | ||
1846 | /** | 1895 | /** |
@@ -1862,7 +1911,8 @@ MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, | |||
1862 | */ | 1911 | */ |
1863 | _MHD_EXTERN enum MHD_StatusCode | 1912 | _MHD_EXTERN enum MHD_StatusCode |
1864 | MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, | 1913 | MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, |
1865 | void *cb); | 1914 | void *cb) |
1915 | MHD_NONNULL(1); | ||
1866 | 1916 | ||
1867 | 1917 | ||
1868 | /** | 1918 | /** |
@@ -1920,7 +1970,8 @@ enum MHD_ThreadingModel | |||
1920 | */ | 1970 | */ |
1921 | _MHD_EXTERN void | 1971 | _MHD_EXTERN void |
1922 | MHD_daemon_threading_model (struct MHD_Daemon *daemon, | 1972 | MHD_daemon_threading_model (struct MHD_Daemon *daemon, |
1923 | enum MHD_ThreadingModel tm); | 1973 | enum MHD_ThreadingModel tm) |
1974 | MHD_NONNULL(1); | ||
1924 | 1975 | ||
1925 | 1976 | ||
1926 | /** | 1977 | /** |
@@ -1950,7 +2001,8 @@ typedef enum MHD_Bool | |||
1950 | _MHD_EXTERN void | 2001 | _MHD_EXTERN void |
1951 | MHD_daemon_accept_policy (struct MHD_Daemon *daemon, | 2002 | MHD_daemon_accept_policy (struct MHD_Daemon *daemon, |
1952 | MHD_AcceptPolicyCallback apc, | 2003 | MHD_AcceptPolicyCallback apc, |
1953 | void *apc_cls); | 2004 | void *apc_cls) |
2005 | MHD_NONNULL(1); | ||
1954 | 2006 | ||
1955 | 2007 | ||
1956 | /** | 2008 | /** |
@@ -1981,7 +2033,8 @@ typedef void * | |||
1981 | _MHD_EXTERN void | 2033 | _MHD_EXTERN void |
1982 | MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, | 2034 | MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, |
1983 | MHD_EarlyUriLogCallback cb, | 2035 | MHD_EarlyUriLogCallback cb, |
1984 | void *cb_cls); | 2036 | void *cb_cls) |
2037 | MHD_NONNULL(1); | ||
1985 | 2038 | ||
1986 | 2039 | ||
1987 | /** | 2040 | /** |
@@ -2043,7 +2096,8 @@ typedef void | |||
2043 | _MHD_EXTERN void | 2096 | _MHD_EXTERN void |
2044 | MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, | 2097 | MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, |
2045 | MHD_NotifyConnectionCallback ncc, | 2098 | MHD_NotifyConnectionCallback ncc, |
2046 | void *ncc_cls); | 2099 | void *ncc_cls) |
2100 | MHD_NONNULL(1); | ||
2047 | 2101 | ||
2048 | 2102 | ||
2049 | /** | 2103 | /** |
@@ -2060,7 +2114,8 @@ MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, | |||
2060 | _MHD_EXTERN void | 2114 | _MHD_EXTERN void |
2061 | MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, | 2115 | MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, |
2062 | size_t memory_limit_b, | 2116 | size_t memory_limit_b, |
2063 | size_t memory_increment_b); | 2117 | size_t memory_increment_b) |
2118 | MHD_NONNULL(1); | ||
2064 | 2119 | ||
2065 | 2120 | ||
2066 | /** | 2121 | /** |
@@ -2073,7 +2128,8 @@ MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, | |||
2073 | */ | 2128 | */ |
2074 | _MHD_EXTERN void | 2129 | _MHD_EXTERN void |
2075 | MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, | 2130 | MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, |
2076 | size_t stack_limit_b); | 2131 | size_t stack_limit_b) |
2132 | MHD_NONNULL(1); | ||
2077 | 2133 | ||
2078 | 2134 | ||
2079 | /** | 2135 | /** |
@@ -2094,7 +2150,8 @@ MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, | |||
2094 | _MHD_EXTERN void | 2150 | _MHD_EXTERN void |
2095 | MHD_daemon_connection_limits (struct MHD_Daemon *daemon, | 2151 | MHD_daemon_connection_limits (struct MHD_Daemon *daemon, |
2096 | unsigned int global_connection_limit, | 2152 | unsigned int global_connection_limit, |
2097 | unsigned int ip_connection_limit); | 2153 | unsigned int ip_connection_limit) |
2154 | MHD_NONNULL(1); | ||
2098 | 2155 | ||
2099 | 2156 | ||
2100 | /** | 2157 | /** |
@@ -2107,7 +2164,8 @@ MHD_daemon_connection_limits (struct MHD_Daemon *daemon, | |||
2107 | */ | 2164 | */ |
2108 | _MHD_EXTERN void | 2165 | _MHD_EXTERN void |
2109 | MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon, | 2166 | MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon, |
2110 | unsigned int timeout_s); | 2167 | unsigned int timeout_s) |
2168 | MHD_NONNULL(1); | ||
2111 | 2169 | ||
2112 | 2170 | ||
2113 | /** | 2171 | /** |
@@ -2142,7 +2200,8 @@ typedef size_t | |||
2142 | _MHD_EXTERN void | 2200 | _MHD_EXTERN void |
2143 | MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, | 2201 | MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, |
2144 | MHD_UnescapeCallback unescape_cb, | 2202 | MHD_UnescapeCallback unescape_cb, |
2145 | void *unescape_cb_cls); | 2203 | void *unescape_cb_cls) |
2204 | MHD_NONNULL(1); | ||
2146 | 2205 | ||
2147 | 2206 | ||
2148 | /** | 2207 | /** |
@@ -2157,7 +2216,8 @@ MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, | |||
2157 | _MHD_EXTERN void | 2216 | _MHD_EXTERN void |
2158 | MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, | 2217 | MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, |
2159 | size_t buf_size, | 2218 | size_t buf_size, |
2160 | const void *buf); | 2219 | const void *buf) |
2220 | MHD_NONNULL(1,3); | ||
2161 | 2221 | ||
2162 | 2222 | ||
2163 | /** | 2223 | /** |
@@ -2169,7 +2229,8 @@ MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, | |||
2169 | */ | 2229 | */ |
2170 | _MHD_EXTERN enum MHD_StatusCode | 2230 | _MHD_EXTERN enum MHD_StatusCode |
2171 | MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, | 2231 | MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, |
2172 | size_t nc_length); | 2232 | size_t nc_length) |
2233 | MHD_NONNULL(1); | ||
2173 | 2234 | ||
2174 | 2235 | ||
2175 | /* ********************* connection options ************** */ | 2236 | /* ********************* connection options ************** */ |
@@ -2185,7 +2246,8 @@ MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, | |||
2185 | */ | 2246 | */ |
2186 | _MHD_EXTERN void | 2247 | _MHD_EXTERN void |
2187 | MHD_connection_set_timeout (struct MHD_Connection *connection, | 2248 | MHD_connection_set_timeout (struct MHD_Connection *connection, |
2188 | unsigned int timeout_s); | 2249 | unsigned int timeout_s) |
2250 | MHD_NONNULL(1); | ||
2189 | 2251 | ||
2190 | 2252 | ||
2191 | /* **************** Request handling functions ***************** */ | 2253 | /* **************** Request handling functions ***************** */ |
@@ -2268,7 +2330,8 @@ _MHD_EXTERN unsigned int | |||
2268 | MHD_request_get_values (struct MHD_Request *request, | 2330 | MHD_request_get_values (struct MHD_Request *request, |
2269 | enum MHD_ValueKind kind, | 2331 | enum MHD_ValueKind kind, |
2270 | MHD_KeyValueIterator iterator, | 2332 | MHD_KeyValueIterator iterator, |
2271 | void *iterator_cls); | 2333 | void *iterator_cls) |
2334 | MHD_NONNULL(1); | ||
2272 | 2335 | ||
2273 | 2336 | ||
2274 | /** | 2337 | /** |
@@ -2300,7 +2363,8 @@ _MHD_EXTERN enum MHD_Bool | |||
2300 | MHD_request_set_value (struct MHD_Request *request, | 2363 | MHD_request_set_value (struct MHD_Request *request, |
2301 | enum MHD_ValueKind kind, | 2364 | enum MHD_ValueKind kind, |
2302 | const char *key, | 2365 | const char *key, |
2303 | const char *value); | 2366 | const char *value) |
2367 | MHD_NONNULL(1,3,4); | ||
2304 | 2368 | ||
2305 | 2369 | ||
2306 | /** | 2370 | /** |
@@ -2316,7 +2380,8 @@ MHD_request_set_value (struct MHD_Request *request, | |||
2316 | _MHD_EXTERN const char * | 2380 | _MHD_EXTERN const char * |
2317 | MHD_request_lookup_value (struct MHD_Request *request, | 2381 | MHD_request_lookup_value (struct MHD_Request *request, |
2318 | enum MHD_ValueKind kind, | 2382 | enum MHD_ValueKind kind, |
2319 | const char *key); | 2383 | const char *key) |
2384 | MHD_NONNULL(1); | ||
2320 | 2385 | ||
2321 | 2386 | ||
2322 | 2387 | ||
@@ -2487,7 +2552,8 @@ MHD_action_suspend (void); | |||
2487 | * @param request the request to resume | 2552 | * @param request the request to resume |
2488 | */ | 2553 | */ |
2489 | _MHD_EXTERN void | 2554 | _MHD_EXTERN void |
2490 | MHD_request_resume (struct MHD_Request *request); | 2555 | MHD_request_resume (struct MHD_Request *request) |
2556 | MHD_NONNULL(1); | ||
2491 | 2557 | ||
2492 | 2558 | ||
2493 | /* **************** Response manipulation functions ***************** */ | 2559 | /* **************** Response manipulation functions ***************** */ |
@@ -2520,7 +2586,8 @@ struct MHD_Response; | |||
2520 | */ | 2586 | */ |
2521 | _MHD_EXTERN struct MHD_Action * | 2587 | _MHD_EXTERN struct MHD_Action * |
2522 | MHD_action_from_response (struct MHD_Response *response, | 2588 | MHD_action_from_response (struct MHD_Response *response, |
2523 | enum MHD_Bool destroy_after_use); | 2589 | enum MHD_Bool destroy_after_use) |
2590 | MHD_NONNULL(1); | ||
2524 | 2591 | ||
2525 | 2592 | ||
2526 | /** | 2593 | /** |
@@ -2531,7 +2598,8 @@ MHD_action_from_response (struct MHD_Response *response, | |||
2531 | * @param request the request for which we force HTTP 1.0 to be used | 2598 | * @param request the request for which we force HTTP 1.0 to be used |
2532 | */ | 2599 | */ |
2533 | _MHD_EXTERN void | 2600 | _MHD_EXTERN void |
2534 | MHD_response_option_v10_only (struct MHD_Response *response); | 2601 | MHD_response_option_v10_only (struct MHD_Response *response) |
2602 | MHD_NONNULL(1); | ||
2535 | 2603 | ||
2536 | 2604 | ||
2537 | /** | 2605 | /** |
@@ -2620,7 +2688,8 @@ typedef void | |||
2620 | _MHD_EXTERN void | 2688 | _MHD_EXTERN void |
2621 | MHD_response_option_termination_callback (struct MHD_Response *response, | 2689 | MHD_response_option_termination_callback (struct MHD_Response *response, |
2622 | MHD_RequestTerminationCallback termination_cb, | 2690 | MHD_RequestTerminationCallback termination_cb, |
2623 | void *termination_cb_cls); | 2691 | void *termination_cb_cls) |
2692 | MHD_NONNULL(1); | ||
2624 | 2693 | ||
2625 | 2694 | ||
2626 | /** | 2695 | /** |
@@ -2837,7 +2906,8 @@ struct MHD_UpgradeResponseHandle; | |||
2837 | _MHD_EXTERN enum MHD_Bool | 2906 | _MHD_EXTERN enum MHD_Bool |
2838 | MHD_upgrade_operation (struct MHD_UpgradeResponseHandle *urh, | 2907 | MHD_upgrade_operation (struct MHD_UpgradeResponseHandle *urh, |
2839 | enum MHD_UpgradeOperation operation, | 2908 | enum MHD_UpgradeOperation operation, |
2840 | ...); | 2909 | ...) |
2910 | MHD_NONNULL(1); | ||
2841 | 2911 | ||
2842 | 2912 | ||
2843 | /** | 2913 | /** |
@@ -2929,7 +2999,8 @@ typedef void | |||
2929 | */ | 2999 | */ |
2930 | _MHD_EXTERN struct MHD_Response * | 3000 | _MHD_EXTERN struct MHD_Response * |
2931 | MHD_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, | 3001 | MHD_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, |
2932 | void *upgrade_handler_cls); | 3002 | void *upgrade_handler_cls) |
3003 | MHD_NONNULL(1); | ||
2933 | 3004 | ||
2934 | 3005 | ||
2935 | /** | 3006 | /** |
@@ -2942,7 +3013,8 @@ MHD_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, | |||
2942 | * @ingroup response | 3013 | * @ingroup response |
2943 | */ | 3014 | */ |
2944 | _MHD_EXTERN void | 3015 | _MHD_EXTERN void |
2945 | MHD_response_queue_for_destroy (struct MHD_Response *response); | 3016 | MHD_response_queue_for_destroy (struct MHD_Response *response) |
3017 | MHD_NONNULL(1); | ||
2946 | 3018 | ||
2947 | 3019 | ||
2948 | /** | 3020 | /** |
@@ -2958,7 +3030,8 @@ MHD_response_queue_for_destroy (struct MHD_Response *response); | |||
2958 | _MHD_EXTERN enum MHD_Bool | 3030 | _MHD_EXTERN enum MHD_Bool |
2959 | MHD_response_add_header (struct MHD_Response *response, | 3031 | MHD_response_add_header (struct MHD_Response *response, |
2960 | const char *header, | 3032 | const char *header, |
2961 | const char *content); | 3033 | const char *content) |
3034 | MHD_NONNULL(1,2,3); | ||
2962 | 3035 | ||
2963 | 3036 | ||
2964 | /** | 3037 | /** |
@@ -2974,7 +3047,8 @@ MHD_response_add_header (struct MHD_Response *response, | |||
2974 | _MHD_EXTERN enum MHD_Bool | 3047 | _MHD_EXTERN enum MHD_Bool |
2975 | MHD_response_add_trailer (struct MHD_Response *response, | 3048 | MHD_response_add_trailer (struct MHD_Response *response, |
2976 | const char *footer, | 3049 | const char *footer, |
2977 | const char *content); | 3050 | const char *content) |
3051 | MHD_NONNULL(1,2,3); | ||
2978 | 3052 | ||
2979 | 3053 | ||
2980 | /** | 3054 | /** |
@@ -2989,7 +3063,8 @@ MHD_response_add_trailer (struct MHD_Response *response, | |||
2989 | _MHD_EXTERN enum MHD_Bool | 3063 | _MHD_EXTERN enum MHD_Bool |
2990 | MHD_response_del_header (struct MHD_Response *response, | 3064 | MHD_response_del_header (struct MHD_Response *response, |
2991 | const char *header, | 3065 | const char *header, |
2992 | const char *content); | 3066 | const char *content) |
3067 | MHD_NONNULL(1,2,3); | ||
2993 | 3068 | ||
2994 | 3069 | ||
2995 | /** | 3070 | /** |
@@ -3005,7 +3080,8 @@ MHD_response_del_header (struct MHD_Response *response, | |||
3005 | _MHD_EXTERN unsigned int | 3080 | _MHD_EXTERN unsigned int |
3006 | MHD_response_get_headers (struct MHD_Response *response, | 3081 | MHD_response_get_headers (struct MHD_Response *response, |
3007 | MHD_KeyValueIterator iterator, | 3082 | MHD_KeyValueIterator iterator, |
3008 | void *iterator_cls); | 3083 | void *iterator_cls) |
3084 | MHD_NONNULL(1); | ||
3009 | 3085 | ||
3010 | 3086 | ||
3011 | /** | 3087 | /** |
@@ -3018,7 +3094,8 @@ MHD_response_get_headers (struct MHD_Response *response, | |||
3018 | */ | 3094 | */ |
3019 | _MHD_EXTERN const char * | 3095 | _MHD_EXTERN const char * |
3020 | MHD_response_get_header (struct MHD_Response *response, | 3096 | MHD_response_get_header (struct MHD_Response *response, |
3021 | const char *key); | 3097 | const char *key) |
3098 | MHD_NONNULL(1,2); | ||
3022 | 3099 | ||
3023 | 3100 | ||
3024 | /* ************Upload and PostProcessor functions ********************** */ | 3101 | /* ************Upload and PostProcessor functions ********************** */ |
@@ -3067,7 +3144,8 @@ typedef struct MHD_Action * | |||
3067 | */ | 3144 | */ |
3068 | _MHD_EXTERN struct MHD_Action * | 3145 | _MHD_EXTERN struct MHD_Action * |
3069 | MHD_action_process_upload (MHD_UploadCallback uc, | 3146 | MHD_action_process_upload (MHD_UploadCallback uc, |
3070 | void *uc_cls); | 3147 | void *uc_cls) |
3148 | MHD_NONNULL(1); | ||
3071 | 3149 | ||
3072 | 3150 | ||
3073 | /** | 3151 | /** |
@@ -3132,7 +3210,8 @@ typedef struct MHD_Action * | |||
3132 | _MHD_EXTERN struct MHD_Action * | 3210 | _MHD_EXTERN struct MHD_Action * |
3133 | MHD_action_parse_post (size_t buffer_size, | 3211 | MHD_action_parse_post (size_t buffer_size, |
3134 | MHD_PostDataIterator iter, | 3212 | MHD_PostDataIterator iter, |
3135 | void *iter_cls); | 3213 | void *iter_cls) |
3214 | MHD_NONNULL(2); | ||
3136 | 3215 | ||
3137 | 3216 | ||
3138 | 3217 | ||
@@ -3303,7 +3382,8 @@ _MHD_EXTERN enum MHD_Bool | |||
3303 | MHD_connection_get_information_sz (struct MHD_Connection *connection, | 3382 | MHD_connection_get_information_sz (struct MHD_Connection *connection, |
3304 | enum MHD_ConnectionInformationType info_type, | 3383 | enum MHD_ConnectionInformationType info_type, |
3305 | union MHD_ConnectionInformation *return_value, | 3384 | union MHD_ConnectionInformation *return_value, |
3306 | size_t return_value_size); | 3385 | size_t return_value_size) |
3386 | MHD_NONNULL(1,3); | ||
3307 | 3387 | ||
3308 | 3388 | ||
3309 | /** | 3389 | /** |
@@ -3415,7 +3495,8 @@ _MHD_EXTERN enum MHD_Bool | |||
3415 | MHD_request_get_information_sz (struct MHD_Request *request, | 3495 | MHD_request_get_information_sz (struct MHD_Request *request, |
3416 | enum MHD_RequestInformationType info_type, | 3496 | enum MHD_RequestInformationType info_type, |
3417 | union MHD_RequestInformation *return_value, | 3497 | union MHD_RequestInformation *return_value, |
3418 | size_t return_value_size); | 3498 | size_t return_value_size) |
3499 | MHD_NONNULL(1,3); | ||
3419 | 3500 | ||
3420 | 3501 | ||
3421 | /** | 3502 | /** |
@@ -3521,7 +3602,8 @@ _MHD_EXTERN enum MHD_Bool | |||
3521 | MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, | 3602 | MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, |
3522 | enum MHD_DaemonInformationType info_type, | 3603 | enum MHD_DaemonInformationType info_type, |
3523 | union MHD_DaemonInformation *return_value, | 3604 | union MHD_DaemonInformation *return_value, |
3524 | size_t return_value_size); | 3605 | size_t return_value_size) |
3606 | MHD_NONNULL(1,3); | ||
3525 | 3607 | ||
3526 | /** | 3608 | /** |
3527 | * Obtain information about the given daemon. | 3609 | * Obtain information about the given daemon. |
@@ -3588,7 +3670,8 @@ MHD_set_panic_func (MHD_PanicCallback cb, | |||
3588 | * shorter afterwards due to elimination of escape sequences) | 3670 | * shorter afterwards due to elimination of escape sequences) |
3589 | */ | 3671 | */ |
3590 | _MHD_EXTERN size_t | 3672 | _MHD_EXTERN size_t |
3591 | MHD_http_unescape (char *val); | 3673 | MHD_http_unescape (char *val) |
3674 | MHD_NONNULL(1); | ||
3592 | 3675 | ||
3593 | 3676 | ||
3594 | /** | 3677 | /** |
diff --git a/src/lib/daemon_create.c b/src/lib/daemon_create.c index ade51c1e..a2173d88 100644 --- a/src/lib/daemon_create.c +++ b/src/lib/daemon_create.c | |||
@@ -89,8 +89,6 @@ MHD_daemon_create (MHD_RequestCallback cb, | |||
89 | struct MHD_Daemon *daemon; | 89 | struct MHD_Daemon *daemon; |
90 | 90 | ||
91 | MHD_check_global_init_(); | 91 | MHD_check_global_init_(); |
92 | if (NULL == cb) | ||
93 | return NULL; | ||
94 | if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon)))) | 92 | if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon)))) |
95 | return NULL; | 93 | return NULL; |
96 | memset (daemon, | 94 | memset (daemon, |
diff --git a/src/lib/daemon_destroy.c b/src/lib/daemon_destroy.c index 1a8f7094..36f23d17 100644 --- a/src/lib/daemon_destroy.c +++ b/src/lib/daemon_destroy.c | |||
@@ -93,8 +93,6 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) | |||
93 | { | 93 | { |
94 | MHD_socket fd; | 94 | MHD_socket fd; |
95 | 95 | ||
96 | if (NULL == daemon) | ||
97 | return; | ||
98 | daemon->shutdown = true; | 96 | daemon->shutdown = true; |
99 | if (daemon->was_quiesced) | 97 | if (daemon->was_quiesced) |
100 | fd = MHD_INVALID_SOCKET; /* Do not use FD if daemon was quiesced */ | 98 | fd = MHD_INVALID_SOCKET; /* Do not use FD if daemon was quiesced */ |
diff --git a/src/lib/daemon_get_fdset.c b/src/lib/daemon_get_fdset.c index afbf3d6b..c3b0dbd9 100644 --- a/src/lib/daemon_get_fdset.c +++ b/src/lib/daemon_get_fdset.c | |||
@@ -62,7 +62,142 @@ MHD_daemon_get_fdset (struct MHD_Daemon *daemon, | |||
62 | fd_set *except_fd_set, | 62 | fd_set *except_fd_set, |
63 | MHD_socket *max_fd) | 63 | MHD_socket *max_fd) |
64 | { | 64 | { |
65 | return -1; | 65 | return MHD_daemon_get_fdset2 (daemon, |
66 | read_fd_set, | ||
67 | write_fd_set, | ||
68 | except_fd_set, | ||
69 | max_fd, | ||
70 | _MHD_SYS_DEFAULT_FD_SETSIZE); | ||
71 | } | ||
72 | |||
73 | |||
74 | /** | ||
75 | * Internal version of #MHD_daemon_get_fdset2(). | ||
76 | * | ||
77 | * @param daemon daemon to get sets from | ||
78 | * @param read_fd_set read set | ||
79 | * @param write_fd_set write set | ||
80 | * @param except_fd_set except set | ||
81 | * @param max_fd increased to largest FD added (if larger | ||
82 | * than existing value); can be NULL | ||
83 | * @param fd_setsize value of FD_SETSIZE | ||
84 | * @return #MHD_SC_OK on success | ||
85 | * @ingroup event | ||
86 | */ | ||
87 | static enum MHD_StatusCode | ||
88 | internal_get_fdset2 (struct MHD_Daemon *daemon, | ||
89 | fd_set *read_fd_set, | ||
90 | fd_set *write_fd_set, | ||
91 | fd_set *except_fd_set, | ||
92 | MHD_socket *max_fd, | ||
93 | unsigned int fd_setsize) | ||
94 | |||
95 | { | ||
96 | struct MHD_Connection *pos; | ||
97 | struct MHD_Connection *posn; | ||
98 | int result = MHD_YES; | ||
99 | MHD_socket ls; | ||
100 | |||
101 | if (daemon->shutdown) | ||
102 | return MHD_NO; | ||
103 | |||
104 | ls = daemon->listen_socket; | ||
105 | if ( (MHD_INVALID_SOCKET != ls) && | ||
106 | (! daemon->was_quiesced) && | ||
107 | (! MHD_add_to_fd_set_ (ls, | ||
108 | read_fd_set, | ||
109 | max_fd, | ||
110 | fd_setsize)) ) | ||
111 | result = MHD_NO; | ||
112 | |||
113 | /* Add all sockets to 'except_fd_set' as well to watch for | ||
114 | * out-of-band data. However, ignore errors if INFO_READ | ||
115 | * or INFO_WRITE sockets will not fit 'except_fd_set'. */ | ||
116 | /* Start from oldest connections. Make sense for W32 FDSETs. */ | ||
117 | for (pos = daemon->connections_tail; NULL != pos; pos = posn) | ||
118 | { | ||
119 | posn = pos->prev; | ||
120 | |||
121 | switch (pos->request.event_loop_info) | ||
122 | { | ||
123 | case MHD_EVENT_LOOP_INFO_READ: | ||
124 | if (! MHD_add_to_fd_set_ (pos->socket_fd, | ||
125 | read_fd_set, | ||
126 | max_fd, | ||
127 | fd_setsize)) | ||
128 | result = MHD_NO; | ||
129 | #ifdef MHD_POSIX_SOCKETS | ||
130 | MHD_add_to_fd_set_ (pos->socket_fd, | ||
131 | except_fd_set, | ||
132 | max_fd, | ||
133 | fd_setsize); | ||
134 | #endif /* MHD_POSIX_SOCKETS */ | ||
135 | break; | ||
136 | case MHD_EVENT_LOOP_INFO_WRITE: | ||
137 | if (! MHD_add_to_fd_set_ (pos->socket_fd, | ||
138 | write_fd_set, | ||
139 | max_fd, | ||
140 | fd_setsize)) | ||
141 | result = MHD_NO; | ||
142 | #ifdef MHD_POSIX_SOCKETS | ||
143 | MHD_add_to_fd_set_ (pos->socket_fd, | ||
144 | except_fd_set, | ||
145 | max_fd, | ||
146 | fd_setsize); | ||
147 | #endif /* MHD_POSIX_SOCKETS */ | ||
148 | break; | ||
149 | case MHD_EVENT_LOOP_INFO_BLOCK: | ||
150 | if ( (NULL == except_fd_set) || | ||
151 | ! MHD_add_to_fd_set_ (pos->socket_fd, | ||
152 | except_fd_set, | ||
153 | max_fd, | ||
154 | fd_setsize)) | ||
155 | result = MHD_NO; | ||
156 | break; | ||
157 | case MHD_EVENT_LOOP_INFO_CLEANUP: | ||
158 | /* this should never happen */ | ||
159 | break; | ||
160 | } | ||
161 | } | ||
162 | #ifdef MHD_WINSOCK_SOCKETS | ||
163 | /* W32 use limited array for fd_set so add INFO_READ/INFO_WRITE sockets | ||
164 | * only after INFO_BLOCK sockets to ensure that INFO_BLOCK sockets will | ||
165 | * not be pushed out. */ | ||
166 | for (pos = daemon->connections_tail; NULL != pos; pos = posn) | ||
167 | { | ||
168 | posn = pos->prev; | ||
169 | MHD_add_to_fd_set_ (pos->socket_fd, | ||
170 | except_fd_set, | ||
171 | max_fd, | ||
172 | fd_setsize); | ||
173 | } | ||
174 | #endif /* MHD_WINSOCK_SOCKETS */ | ||
175 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) | ||
176 | { | ||
177 | struct MHD_UpgradeResponseHandle *urh; | ||
178 | |||
179 | for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev) | ||
180 | { | ||
181 | if (MHD_NO == | ||
182 | urh_to_fdset (urh, | ||
183 | read_fd_set, | ||
184 | write_fd_set, | ||
185 | except_fd_set, | ||
186 | max_fd, | ||
187 | fd_setsize)) | ||
188 | result = MHD_NO; | ||
189 | } | ||
190 | } | ||
191 | #endif | ||
192 | #if DEBUG_CONNECT | ||
193 | #ifdef HAVE_MESSAGES | ||
194 | if (NULL != max_fd) | ||
195 | MHD_DLOG (daemon, | ||
196 | _("Maximum socket in select set: %d\n"), | ||
197 | *max_fd); | ||
198 | #endif | ||
199 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | ||
200 | return result; | ||
66 | } | 201 | } |
67 | 202 | ||
68 | 203 | ||
@@ -101,7 +236,34 @@ MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon, | |||
101 | MHD_socket *max_fd, | 236 | MHD_socket *max_fd, |
102 | unsigned int fd_setsize) | 237 | unsigned int fd_setsize) |
103 | { | 238 | { |
104 | return -1; | 239 | if ( (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_model) || |
240 | (MHD_ELS_POLL == daemon->event_loop_syscall) ) | ||
241 | return MHD_SC_CONFIGURATION_MISSMATCH_FOR_GET_FDSET; | ||
242 | |||
243 | #ifdef EPOLL_SUPPORT | ||
244 | if (MHD_ELS_EPOLL == daemon->event_loop_syscall) | ||
245 | { | ||
246 | if (daemon->shutdown) | ||
247 | return MHD_SC_DAEMON_ALREADY_SHUTDOWN; | ||
248 | |||
249 | /* we're in epoll mode, use the epoll FD as a stand-in for | ||
250 | the entire event set */ | ||
251 | |||
252 | return MHD_add_to_fd_set_ (daemon->epoll_fd, | ||
253 | read_fd_set, | ||
254 | max_fd, | ||
255 | fd_setsize) | ||
256 | ? MHD_SC_OK | ||
257 | : MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; | ||
258 | } | ||
259 | #endif | ||
260 | |||
261 | return internal_get_fdset2 (daemon, | ||
262 | read_fd_set, | ||
263 | write_fd_set, | ||
264 | except_fd_set, | ||
265 | max_fd, | ||
266 | fd_setsize); | ||
105 | } | 267 | } |
106 | 268 | ||
107 | /* end of daemon_get_fdset.c */ | 269 | /* end of daemon_get_fdset.c */ |
diff --git a/src/lib/internal.h b/src/lib/internal.h index 5b147df8..17e5c634 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h | |||
@@ -826,6 +826,202 @@ struct MHD_Connection | |||
826 | }; | 826 | }; |
827 | 827 | ||
828 | 828 | ||
829 | #ifdef UPGRADE_SUPPORT | ||
830 | /** | ||
831 | * Buffer we use for upgrade response handling in the unlikely | ||
832 | * case where the memory pool was so small it had no buffer | ||
833 | * capacity left. Note that we don't expect to _ever_ use this | ||
834 | * buffer, so it's mostly wasted memory (except that it allows | ||
835 | * us to handle a tricky error condition nicely). So no need to | ||
836 | * make this one big. Applications that want to perform well | ||
837 | * should just pick an adequate size for the memory pools. | ||
838 | */ | ||
839 | #define RESERVE_EBUF_SIZE 8 | ||
840 | |||
841 | /** | ||
842 | * Context we pass to epoll() for each of the two sockets | ||
843 | * of a `struct MHD_UpgradeResponseHandle`. We need to do | ||
844 | * this so we can distinguish the two sockets when epoll() | ||
845 | * gives us event notifications. | ||
846 | */ | ||
847 | struct UpgradeEpollHandle | ||
848 | { | ||
849 | /** | ||
850 | * Reference to the overall response handle this struct is | ||
851 | * included within. | ||
852 | */ | ||
853 | struct MHD_UpgradeResponseHandle *urh; | ||
854 | |||
855 | /** | ||
856 | * The socket this event is kind-of about. Note that this is NOT | ||
857 | * necessarily the socket we are polling on, as for when we read | ||
858 | * from TLS, we epoll() on the connection's socket | ||
859 | * (`urh->connection->socket_fd`), while this then the application's | ||
860 | * socket (where the application will read from). Nevertheless, for | ||
861 | * the application to read, we need to first read from TLS, hence | ||
862 | * the two are related. | ||
863 | * | ||
864 | * Similarly, for writing to TLS, this epoll() will be on the | ||
865 | * connection's `socket_fd`, and this will merely be the FD which | ||
866 | * the applicatio would write to. Hence this struct must always be | ||
867 | * interpreted based on which field in `struct | ||
868 | * MHD_UpgradeResponseHandle` it is (`app` or `mhd`). | ||
869 | */ | ||
870 | MHD_socket socket; | ||
871 | |||
872 | /** | ||
873 | * IO-state of the @e socket (or the connection's `socket_fd`). | ||
874 | */ | ||
875 | enum MHD_EpollState celi; | ||
876 | |||
877 | }; | ||
878 | |||
879 | |||
880 | /** | ||
881 | * Handle given to the application to manage special | ||
882 | * actions relating to MHD responses that "upgrade" | ||
883 | * the HTTP protocol (i.e. to WebSockets). | ||
884 | */ | ||
885 | struct MHD_UpgradeResponseHandle | ||
886 | { | ||
887 | /** | ||
888 | * The connection for which this is an upgrade handle. Note that | ||
889 | * because a response may be shared over many connections, this may | ||
890 | * not be the only upgrade handle for the response of this connection. | ||
891 | */ | ||
892 | struct MHD_Connection *connection; | ||
893 | |||
894 | #ifdef HTTPS_SUPPORT | ||
895 | /** | ||
896 | * Kept in a DLL per daemon. | ||
897 | */ | ||
898 | struct MHD_UpgradeResponseHandle *next; | ||
899 | |||
900 | /** | ||
901 | * Kept in a DLL per daemon. | ||
902 | */ | ||
903 | struct MHD_UpgradeResponseHandle *prev; | ||
904 | |||
905 | #ifdef EPOLL_SUPPORT | ||
906 | /** | ||
907 | * Next pointer for the EDLL listing urhs that are epoll-ready. | ||
908 | */ | ||
909 | struct MHD_UpgradeResponseHandle *nextE; | ||
910 | |||
911 | /** | ||
912 | * Previous pointer for the EDLL listing urhs that are epoll-ready. | ||
913 | */ | ||
914 | struct MHD_UpgradeResponseHandle *prevE; | ||
915 | |||
916 | /** | ||
917 | * Specifies whether urh already in EDLL list of ready connections. | ||
918 | */ | ||
919 | bool in_eready_list; | ||
920 | #endif | ||
921 | |||
922 | /** | ||
923 | * The buffer for receiving data from TLS to | ||
924 | * be passed to the application. Contains @e in_buffer_size | ||
925 | * bytes (unless @e in_buffer_size is zero). Do not free! | ||
926 | */ | ||
927 | char *in_buffer; | ||
928 | |||
929 | /** | ||
930 | * The buffer for receiving data from the application to | ||
931 | * be passed to TLS. Contains @e out_buffer_size | ||
932 | * bytes (unless @e out_buffer_size is zero). Do not free! | ||
933 | */ | ||
934 | char *out_buffer; | ||
935 | |||
936 | /** | ||
937 | * Size of the @e in_buffer. | ||
938 | * Set to 0 if the TLS connection went down for reading or socketpair | ||
939 | * went down for writing. | ||
940 | */ | ||
941 | size_t in_buffer_size; | ||
942 | |||
943 | /** | ||
944 | * Size of the @e out_buffer. | ||
945 | * Set to 0 if the TLS connection went down for writing or socketpair | ||
946 | * went down for reading. | ||
947 | */ | ||
948 | size_t out_buffer_size; | ||
949 | |||
950 | /** | ||
951 | * Number of bytes actually in use in the @e in_buffer. Can be larger | ||
952 | * than @e in_buffer_size if and only if @a in_buffer_size is zero and | ||
953 | * we still have bytes that can be forwarded. | ||
954 | * Reset to zero if all data was forwarded to socketpair or | ||
955 | * if socketpair went down for writing. | ||
956 | */ | ||
957 | size_t in_buffer_used; | ||
958 | |||
959 | /** | ||
960 | * Number of bytes actually in use in the @e out_buffer. Can be larger | ||
961 | * than @e out_buffer_size if and only if @a out_buffer_size is zero and | ||
962 | * we still have bytes that can be forwarded. | ||
963 | * Reset to zero if all data was forwarded to TLS connection or | ||
964 | * if TLS connection went down for writing. | ||
965 | */ | ||
966 | size_t out_buffer_used; | ||
967 | |||
968 | /** | ||
969 | * The socket we gave to the application (r/w). | ||
970 | */ | ||
971 | struct UpgradeEpollHandle app; | ||
972 | |||
973 | /** | ||
974 | * If @a app_sock was a socketpair, our end of it, otherwise | ||
975 | * #MHD_INVALID_SOCKET; (r/w). | ||
976 | */ | ||
977 | struct UpgradeEpollHandle mhd; | ||
978 | |||
979 | /** | ||
980 | * Emergency IO buffer we use in case the memory pool has literally | ||
981 | * nothing left. | ||
982 | */ | ||
983 | char e_buf[RESERVE_EBUF_SIZE]; | ||
984 | |||
985 | #endif /* HTTPS_SUPPORT */ | ||
986 | |||
987 | /** | ||
988 | * Set to true after the application finished with the socket | ||
989 | * by #MHD_UPGRADE_ACTION_CLOSE. | ||
990 | * | ||
991 | * When BOTH @e was_closed (changed by command from application) | ||
992 | * AND @e clean_ready (changed internally by MHD) are set to | ||
993 | * #MHD_YES, function #MHD_resume_connection() will move this | ||
994 | * connection to cleanup list. | ||
995 | * @remark This flag could be changed from any thread. | ||
996 | */ | ||
997 | volatile bool was_closed; | ||
998 | |||
999 | /** | ||
1000 | * Set to true if connection is ready for cleanup. | ||
1001 | * | ||
1002 | * In TLS mode functions #MHD_connection_finish_forward_() must | ||
1003 | * be called before setting this flag to true. | ||
1004 | * | ||
1005 | * In thread-per-connection mode, true in this flag means | ||
1006 | * that connection's thread exited or about to exit and will | ||
1007 | * not use MHD_Connection::urh data anymore. | ||
1008 | * | ||
1009 | * In any mode true in this flag also means that | ||
1010 | * MHD_Connection::urh data will not be used for socketpair | ||
1011 | * forwarding and forwarding itself is finished. | ||
1012 | * | ||
1013 | * When BOTH @e was_closed (changed by command from application) | ||
1014 | * AND @e clean_ready (changed internally by MHD) are set to | ||
1015 | * true, function #MHD_resume_connection() will move this | ||
1016 | * connection to cleanup list. | ||
1017 | * @remark This flag could be changed from thread that process | ||
1018 | * connection's recv(), send() and response. | ||
1019 | */ | ||
1020 | bool clean_ready; | ||
1021 | }; | ||
1022 | #endif /* UPGRADE_SUPPORT */ | ||
1023 | |||
1024 | |||
829 | /** | 1025 | /** |
830 | * State kept for each MHD daemon. All connections are kept in two | 1026 | * State kept for each MHD daemon. All connections are kept in two |
831 | * doubly-linked lists. The first one reflects the state of the | 1027 | * doubly-linked lists. The first one reflects the state of the |
@@ -910,6 +1106,22 @@ struct MHD_Daemon | |||
910 | 1106 | ||
911 | 1107 | ||
912 | #if HTTPS_SUPPORT | 1108 | #if HTTPS_SUPPORT |
1109 | #ifdef UPGRADE_SUPPORT | ||
1110 | /** | ||
1111 | * Head of DLL of upgrade response handles we are processing. | ||
1112 | * Used for upgraded TLS connections when thread-per-connection | ||
1113 | * is not used. | ||
1114 | */ | ||
1115 | struct MHD_UpgradeResponseHandle *urh_head; | ||
1116 | |||
1117 | /** | ||
1118 | * Tail of DLL of upgrade response handles we are processing. | ||
1119 | * Used for upgraded TLS connections when thread-per-connection | ||
1120 | * is not used. | ||
1121 | */ | ||
1122 | struct MHD_UpgradeResponseHandle *urh_tail; | ||
1123 | #endif /* UPGRADE_SUPPORT */ | ||
1124 | |||
913 | /** | 1125 | /** |
914 | * Which TLS backend should be used. NULL for no TLS. | 1126 | * Which TLS backend should be used. NULL for no TLS. |
915 | * This is merely the handle to the dlsym() object, not | 1127 | * This is merely the handle to the dlsym() object, not |
@@ -1012,13 +1224,10 @@ struct MHD_Daemon | |||
1012 | */ | 1224 | */ |
1013 | struct MHD_Connection *eready_tail; | 1225 | struct MHD_Connection *eready_tail; |
1014 | 1226 | ||
1015 | #ifdef EPOLL_SUPPORT | ||
1016 | /** | 1227 | /** |
1017 | * Pointer to marker used to indicate ITC slot in epoll sets. | 1228 | * Pointer to marker used to indicate ITC slot in epoll sets. |
1018 | */ | 1229 | */ |
1019 | const char *epoll_itc_marker; | 1230 | const char *epoll_itc_marker; |
1020 | #endif | ||
1021 | |||
1022 | #ifdef UPGRADE_SUPPORT | 1231 | #ifdef UPGRADE_SUPPORT |
1023 | /** | 1232 | /** |
1024 | * Head of EDLL of upgraded connections ready for processing (in epoll mode). | 1233 | * Head of EDLL of upgraded connections ready for processing (in epoll mode). |
diff --git a/src/lib/request.c b/src/lib/request.c index b834ba9d..6264111e 100644 --- a/src/lib/request.c +++ b/src/lib/request.c | |||
@@ -47,8 +47,6 @@ MHD_request_get_values (struct MHD_Request *request, | |||
47 | int ret; | 47 | int ret; |
48 | struct MHD_HTTP_Header *pos; | 48 | struct MHD_HTTP_Header *pos; |
49 | 49 | ||
50 | if (NULL == request) | ||
51 | return -1; | ||
52 | ret = 0; | 50 | ret = 0; |
53 | for (pos = request->headers_received; | 51 | for (pos = request->headers_received; |
54 | NULL != pos; | 52 | NULL != pos; |
@@ -143,8 +141,6 @@ MHD_request_lookup_value (struct MHD_Request *request, | |||
143 | { | 141 | { |
144 | struct MHD_HTTP_Header *pos; | 142 | struct MHD_HTTP_Header *pos; |
145 | 143 | ||
146 | if (NULL == request) | ||
147 | return NULL; | ||
148 | for (pos = request->headers_received; | 144 | for (pos = request->headers_received; |
149 | NULL != pos; | 145 | NULL != pos; |
150 | pos = pos->next) | 146 | pos = pos->next) |
diff --git a/src/lib/response.c b/src/lib/response.c index 2a9a2604..ff23c7fd 100644 --- a/src/lib/response.c +++ b/src/lib/response.c | |||
@@ -172,9 +172,6 @@ MHD_response_del_header (struct MHD_Response *response, | |||
172 | struct MHD_HTTP_Header *pos; | 172 | struct MHD_HTTP_Header *pos; |
173 | struct MHD_HTTP_Header *prev; | 173 | struct MHD_HTTP_Header *prev; |
174 | 174 | ||
175 | if ( (NULL == header) || | ||
176 | (NULL == content) ) | ||
177 | return MHD_NO; | ||
178 | prev = NULL; | 175 | prev = NULL; |
179 | pos = response->first_header; | 176 | pos = response->first_header; |
180 | while (NULL != pos) | 177 | while (NULL != pos) |
@@ -248,8 +245,6 @@ MHD_response_get_header (struct MHD_Response *response, | |||
248 | { | 245 | { |
249 | struct MHD_HTTP_Header *pos; | 246 | struct MHD_HTTP_Header *pos; |
250 | 247 | ||
251 | if (NULL == key) | ||
252 | return NULL; | ||
253 | for (pos = response->first_header; | 248 | for (pos = response->first_header; |
254 | NULL != pos; | 249 | NULL != pos; |
255 | pos = pos->next) | 250 | pos = pos->next) |