From 5e99e18f2db625fbe937f99a7f2916e2eee82008 Mon Sep 17 00:00:00 2001 From: ng0 Date: Tue, 2 Jul 2019 22:21:45 +0000 Subject: [PATCH] mhd_send: start adding logic from send_param_adapter. --- src/microhttpd/mhd_send.c | 11 +++++++++++ src/microhttpd/mhd_send.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 85616e52..2240ee0c 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c @@ -85,6 +85,17 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, const MHD_SCKT_OPT_BOOL_ off_val = 0; const MHD_SCKT_OPT_BOOL_ on_val = 1; + // error handling from send_param_adapter() + if ( (MHD_INVALID_SOCKET == s) || + (MHD_CONNECTION_CLOSED == connection->state) ) + { + return MHD_ERR_NOTCONN_; + } + + // from send_param_adapter() + if (buffer_size > MHD_SCKT_SEND_MAX_SIZE_) + buffer_size = MHD_SCKT_SEND_MAX_SIZE_; /* return value limit */ + // new code... /* Get socket options, change/set options if necessary. */ switch (options) diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h index 11b9bce6..64b4f240 100644 --- a/src/microhttpd/mhd_send.h +++ b/src/microhttpd/mhd_send.h @@ -34,6 +34,7 @@ #endif /* HAVE_STDBOOL_H */ #include #include "mhd_sockets.h" +#include "connection.h" enum MHD_SendSocketOptions {