[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36164 - in libmicrohttpd: . src/examples src/include src/m
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36164 - in libmicrohttpd: . src/examples src/include src/microspdy src/testcurl/https src/testspdy |
Date: |
Sun, 2 Aug 2015 19:11:48 +0200 |
Author: grothoff
Date: 2015-08-02 19:11:48 +0200 (Sun, 02 Aug 2015)
New Revision: 36164
Modified:
libmicrohttpd/ChangeLog
libmicrohttpd/src/examples/demo.c
libmicrohttpd/src/examples/mhd2spdy_spdy.c
libmicrohttpd/src/include/microhttpd.h
libmicrohttpd/src/include/platform_interface.h
libmicrohttpd/src/microspdy/daemon.c
libmicrohttpd/src/microspdy/internal.h
libmicrohttpd/src/microspdy/session.c
libmicrohttpd/src/testcurl/https/test_https_time_out.c
libmicrohttpd/src/testcurl/https/test_tls_extensions.c
libmicrohttpd/src/testspdy/test_new_connection.c
libmicrohttpd/src/testspdy/test_notls.c
libmicrohttpd/src/testspdy/test_request_response.c
Log:
fix #3926: ignore close() errors other than EBADF
Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog 2015-08-02 14:48:32 UTC (rev 36163)
+++ libmicrohttpd/ChangeLog 2015-08-02 17:11:48 UTC (rev 36164)
@@ -1,3 +1,7 @@
+Sun Aug 2 19:08:20 CEST 2015
+ Ignore close() errors on sockets except for EBADF,
+ fixes #3926. -CG
+
Sat Jun 27 22:16:27 CEST 2015
Make sure to decrement connection counter before
calling connection notifier so that
Modified: libmicrohttpd/src/examples/demo.c
===================================================================
--- libmicrohttpd/src/examples/demo.c 2015-08-02 14:48:32 UTC (rev 36163)
+++ libmicrohttpd/src/examples/demo.c 2015-08-02 17:11:48 UTC (rev 36164)
@@ -574,7 +574,7 @@
uc->filename,
strerror (errno));
uc->response = internal_error_response;
- close (uc->fd);
+ (void) close (uc->fd);
uc->fd = -1;
if (NULL != uc->filename)
{
Modified: libmicrohttpd/src/examples/mhd2spdy_spdy.c
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_spdy.c 2015-08-02 14:48:32 UTC (rev
36163)
+++ libmicrohttpd/src/examples/mhd2spdy_spdy.c 2015-08-02 17:11:48 UTC (rev
36164)
@@ -69,20 +69,20 @@
(void)session;
(void)stream_id;
(void)user_data;
-
+
ssize_t ret;
assert(NULL != source);
assert(NULL != source->ptr);
struct Proxy *proxy = (struct Proxy *)(source->ptr);
void *newbody;
-
-
+
+
if(length < 1)
{
PRINT_INFO("spdy_cb_data_source_read: length is 0");
return 0;
}
-
+
if(!proxy->received_body_size)//nothing to write now
{
if(proxy->receiving_done)
@@ -93,7 +93,7 @@
PRINT_INFO("POST SPDYLAY_ERR_DEFERRED");
return SPDYLAY_ERR_DEFERRED;//TODO SPDYLAY_ERR_DEFERRED should
be used
}
-
+
if(length >= proxy->received_body_size)
{
ret = proxy->received_body_size;
@@ -113,15 +113,15 @@
free(proxy->received_body);
proxy->received_body = newbody;
proxy->received_body_size -= ret;
-
+
if(0 == proxy->received_body_size && proxy->receiving_done)
{
PRINT_INFO("POST spdy EOF");
*eof = 1;
}
-
+
PRINT_INFO2("given POST bytes to spdylay: %zd", ret);
-
+
return ret;
}
@@ -141,13 +141,13 @@
{
(void)session;
(void)flags;
-
+
//PRINT_INFO("spdy_cb_send called");
struct SPDY_Connection *connection;
ssize_t rv;
connection = (struct SPDY_Connection*)user_data;
connection->want_io = IO_NONE;
-
+
if(glob_opt.ignore_rst_stream
&& 16 == length
&& 0x80 == data[0]
@@ -160,7 +160,7 @@
return 16;
}
glob_opt.ignore_rst_stream = false;
-
+
if(connection->is_tls)
{
ERR_clear_error();
@@ -178,14 +178,14 @@
}
else
{
- rv = write(connection->fd,
+ rv = write(connection->fd,
data,
length);
-
+
if (rv < 0)
{
switch(errno)
- {
+ {
case EAGAIN:
#if EAGAIN != EWOULDBLOCK
case EWOULDBLOCK:
@@ -193,18 +193,18 @@
connection->want_io |= WANT_WRITE;
rv = SPDYLAY_ERR_WOULDBLOCK;
break;
-
+
default:
rv = SPDYLAY_ERR_CALLBACK_FAILURE;
}
}
}
-
+
PRINT_INFO2("%zd bytes written by spdy", rv);
-
+
if(rv > 0)
UPDATE_STAT(glob_stat.spdy_bytes_sent, rv);
-
+
return rv;
}
@@ -218,16 +218,16 @@
static ssize_t
spdy_cb_recv(spdylay_session *session,
uint8_t *buf,
- size_t length,
+ size_t length,
int flags,
void *user_data)
{
(void)session;
(void)flags;
-
+
struct SPDY_Connection *connection;
ssize_t rv;
-
+
connection = (struct SPDY_Connection*)user_data;
//prevent monopolizing everything
if(!(++connection->counter % 10)) return SPDYLAY_ERR_WOULDBLOCK;
@@ -251,14 +251,14 @@
}
else
{
- rv = read(connection->fd,
+ rv = read(connection->fd,
buf,
length);
-
+
if (rv < 0)
{
switch(errno)
- {
+ {
case EAGAIN:
#if EAGAIN != EWOULDBLOCK
case EWOULDBLOCK:
@@ -266,7 +266,7 @@
connection->want_io |= WANT_READ;
rv = SPDYLAY_ERR_WOULDBLOCK;
break;
-
+
default:
rv = SPDYLAY_ERR_CALLBACK_FAILURE;
}
@@ -274,10 +274,10 @@
else if(rv == 0)
rv = SPDYLAY_ERR_EOF;
}
-
+
if(rv > 0)
UPDATE_STAT(glob_stat.spdy_bytes_received, rv);
-
+
return rv;
}
@@ -289,10 +289,10 @@
void *user_data)
{
(void)user_data;
-
+
int32_t stream_id;
struct Proxy *proxy;
-
+
switch(type) {
case SPDYLAY_SYN_STREAM:
stream_id = frame->syn_stream.stream_id;
@@ -324,7 +324,7 @@
void *user_data)
{
(void)user_data;
-
+
char **nv;
int32_t stream_id;
struct Proxy * proxy;
@@ -371,7 +371,7 @@
return;
break;
}
-
+
glob_opt.spdy_data_received = true;
}
@@ -390,16 +390,16 @@
{
(void)status_code;
(void)user_data;
-
+
struct Proxy * proxy = spdylay_session_get_stream_user_data(session,
stream_id);
-
+
assert(NULL != proxy);
-
+
--glob_opt.streams_opened;
--proxy->spdy_connection->streams_opened;
PRINT_INFO2("closing stream: str opened %i; remove proxy %i",
glob_opt.streams_opened, proxy->id);
-
- DLL_remove(proxy->spdy_connection->proxies_head,
proxy->spdy_connection->proxies_tail, proxy);
+
+ DLL_remove(proxy->spdy_connection->proxies_head,
proxy->spdy_connection->proxies_tail, proxy);
if(proxy->http_active)
{
proxy->spdy_active = false;
@@ -425,16 +425,16 @@
{
(void)flags;
(void)user_data;
-
+
struct Proxy *proxy;
proxy = spdylay_session_get_stream_user_data(session, stream_id);
-
+
if(NULL == proxy)
{
PRINT_INFO("proxy in spdy_cb_on_data_chunk_recv is NULL)");
return;
}
-
+
if(!copy_buffer(data, len, &proxy->http_body, &proxy->http_body_size))
{
//TODO handle it better?
@@ -469,7 +469,7 @@
{
(void)length;
(void)user_data;
-
+
if(flags & SPDYLAY_DATA_FLAG_FIN)
{
struct Proxy *proxy;
@@ -514,10 +514,10 @@
void *arg)
{
(void)ssl;
-
+
int rv;
uint16_t *spdy_proto_version;
-
+
/* spdylay_select_next_protocol() selects SPDY protocol version the
Spdylay library supports. */
rv = spdylay_select_next_protocol(out, outlen, in, inlen);
@@ -554,7 +554,7 @@
int fd)
{
int rv;
-
+
if(SSL_set_fd(ssl, fd) == 0)
spdy_dief("SSL_set_fd", ERR_error_string(ERR_get_error(), NULL));
@@ -562,7 +562,7 @@
rv = SSL_connect(ssl);
if(rv <= 0)
PRINT_INFO2("SSL_connect %s", ERR_error_string(ERR_get_error(), NULL));
-
+
return rv;
}
@@ -580,7 +580,7 @@
int rv;
char service[NI_MAXSERV];
struct addrinfo *res, *rp;
-
+
//TODO checks
snprintf(service, sizeof(service), "%u", port);
memset(&hints, 0, sizeof(struct addrinfo));
@@ -601,11 +601,11 @@
errno == EINTR);
if(rv == 0)
break;
- close(fd);
+ MHD_socket_close_ (fd);
fd = -1;
}
freeaddrinfo(res);
-
+
return fd;
}
@@ -615,14 +615,14 @@
{
int flags;
int rv;
-
+
while((flags = fcntl(fd, F_GETFL, 0)) == -1 && errno == EINTR);
-
+
if(flags == -1)
spdy_dief("fcntl", strerror(errno));
-
+
while((rv = fcntl(fd, F_SETFL, flags | O_NONBLOCK)) == -1 && errno == EINTR);
-
+
if(rv == -1)
spdy_dief("fcntl", strerror(errno));
}
@@ -636,7 +636,7 @@
{
int val = 1;
int rv;
-
+
rv = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, (socklen_t)sizeof(val));
if(rv == -1)
spdy_dief("setsockopt", strerror(errno));
@@ -669,14 +669,14 @@
*/
bool
spdy_ctl_select(fd_set * read_fd_set,
- fd_set * write_fd_set,
+ fd_set * write_fd_set,
fd_set * except_fd_set,
struct SPDY_Connection *connection)
{
(void)except_fd_set;
-
+
bool ret = false;
-
+
if(spdylay_session_want_read(connection->session) ||
connection->want_io & WANT_READ)
{
@@ -689,7 +689,7 @@
FD_SET(connection->fd, write_fd_set);
ret = true;
}
-
+
return ret;
}
@@ -701,7 +701,7 @@
spdy_exec_io(struct SPDY_Connection *connection)
{
int rv;
-
+
rv = spdylay_session_recv(connection->session);
if(rv != 0)
{
@@ -711,7 +711,7 @@
rv = spdylay_session_send(connection->session);
if(rv != 0)
PRINT_INFO2("spdylay_session_send %i", rv);
-
+
return rv;
}
@@ -740,7 +740,7 @@
PRINT_INFO("Could not open file descriptor");
return NULL;
}
-
+
if(is_tls)
{
ssl = SSL_new(glob_opt.ssl_ctx);
@@ -747,7 +747,7 @@
if(ssl == NULL) {
spdy_dief("SSL_new", ERR_error_string(ERR_get_error(), NULL));
}
-
+
//TODO non-blocking
/* To simplify the program, we perform SSL/TLS handshake in blocking
I/O. */
@@ -767,7 +767,7 @@
if(NULL == (connection = au_malloc(sizeof(struct SPDY_Connection))))
goto free_and_fail;
-
+
connection->is_tls = is_tls;
connection->ssl = ssl;
connection->want_io = IO_NONE;
@@ -784,11 +784,11 @@
if(rv != 0) {
spdy_diec("spdylay_session_client_new", rv);
}
-
+
connection->fd = fd;
return connection;
-
+
//for GOTO
free_and_fail:
if(NULL != connection)
@@ -796,15 +796,15 @@
free(connection->host);
free(connection);
}
-
+
if(is_tls)
SSL_shutdown(ssl);
-
- close(fd);
-
+
+ MHD_socket_close_ (fd);
+
if(is_tls)
SSL_free(ssl);
-
+
return NULL;
}
@@ -814,7 +814,7 @@
{
struct Proxy *proxy;
struct Proxy *proxy_next;
-
+
if(NULL != connection)
{
for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy_next)
@@ -847,7 +847,7 @@
uint16_t port;
struct SPDY_Connection *connection;
spdylay_data_provider post_data;
-
+
if(glob_opt.only_proxy)
{
connection = glob_opt.spdy_connection;
@@ -861,7 +861,7 @@
break;
connection = connection->next;
}
-
+
if(NULL == connection)
{
//connect to host
@@ -877,13 +877,13 @@
connection = glob_opt.spdy_connection;
}
}
-
+
if(NULL == connection)
{
PRINT_INFO("there is no proxy!");
return -1;
}
-
+
proxy->spdy_connection = connection;
if(with_body)
{
@@ -893,7 +893,7 @@
}
else
ret = spdylay_submit_request(connection->session, 0, nv, NULL, proxy);
-
+
if(ret != 0) {
spdy_diec("spdylay_spdy_submit_request", ret);
}
@@ -901,7 +901,7 @@
if(NULL != connection->proxies_head)
PRINT_INFO2("before proxy %i", connection->proxies_head->id);
DLL_insert(connection->proxies_head, connection->proxies_tail, proxy);
-
+
return ret;
}
@@ -914,11 +914,11 @@
{
struct SPDY_Connection *connection;
struct Proxy *proxy;
-
+
*real_size = 0;
if(max_size<1)
return;
-
+
if(NULL != glob_opt.spdy_connection)
{
spdy_ctl_poll(&(fds[*real_size]), glob_opt.spdy_connection);
@@ -926,7 +926,7 @@
{
//PRINT_INFO("TODO drop connection");
glob_opt.streams_opened -= glob_opt.spdy_connection->streams_opened;
-
+
for(proxy = glob_opt.spdy_connection->proxies_head; NULL != proxy;
proxy=proxy->next)
{
abort();
@@ -943,9 +943,9 @@
++(*real_size);
}
}
-
+
connection = glob_opt.spdy_connections_head;
-
+
while(NULL != connection && *real_size < max_size)
{
assert(!glob_opt.only_proxy);
@@ -956,7 +956,7 @@
glob_opt.streams_opened -= connection->streams_opened;
DLL_remove(glob_opt.spdy_connections_head,
glob_opt.spdy_connections_tail, connection);
glob_opt.total_spdy_connections--;
-
+
for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy->next)
{
abort();
@@ -973,7 +973,7 @@
}
connection = connection->next;
}
-
+
//, "TODO max num of conn reached; close something"
assert(NULL == connection);
}
@@ -981,7 +981,7 @@
int
spdy_get_selectfdset(fd_set * read_fd_set,
- fd_set * write_fd_set,
+ fd_set * write_fd_set,
fd_set * except_fd_set,
struct SPDY_Connection *connections[],
unsigned int max_size,
@@ -991,20 +991,20 @@
struct SPDY_Connection *next_connection;
bool ret;
int maxfd = 0;
-
+
*real_size = 0;
if(max_size<1)
return 0;
-
+
if(NULL != glob_opt.spdy_connection)
{
ret = spdy_ctl_select(read_fd_set,
- write_fd_set,
+ write_fd_set,
except_fd_set, glob_opt.spdy_connection);
if(!ret)
{
glob_opt.streams_opened -= glob_opt.spdy_connection->streams_opened;
-
+
PRINT_INFO("spdy_free_connection in spdy_get_selectfdset");
spdy_free_connection(glob_opt.spdy_connection);
glob_opt.spdy_connection = NULL;
@@ -1016,16 +1016,16 @@
if(maxfd < glob_opt.spdy_connection->fd) maxfd =
glob_opt.spdy_connection->fd;
}
}
-
+
connection = glob_opt.spdy_connections_head;
-
+
while(NULL != connection && *real_size < max_size)
{
assert(!glob_opt.only_proxy);
ret = spdy_ctl_select(read_fd_set,
- write_fd_set,
+ write_fd_set,
except_fd_set, connection);
-
+
next_connection = connection->next;
if(!ret)
{
@@ -1032,7 +1032,7 @@
glob_opt.streams_opened -= connection->streams_opened;
DLL_remove(glob_opt.spdy_connections_head,
glob_opt.spdy_connections_tail, connection);
glob_opt.total_spdy_connections--;
-
+
PRINT_INFO("spdy_free_connection in spdy_get_selectfdset");
spdy_free_connection(connection);
}
@@ -1044,10 +1044,10 @@
}
connection = next_connection;
}
-
+
//, "TODO max num of conn reached; close something"
assert(NULL == connection);
-
+
return maxfd;
}
@@ -1060,7 +1060,7 @@
int i;
int ret;
struct Proxy *proxy;
-
+
for(i=0; i<size; ++i)
{
// PRINT_INFO2("exec about to be called for %s", connections[i]->host);
@@ -1070,10 +1070,10 @@
//PRINT_INFO2("%i",ret);
//if((spdy_pollfds[i].revents & POLLHUP) || (spdy_pollfds[0].revents &
POLLERR))
// PRINT_INFO("SPDY SPDY_Connection error");
-
+
//TODO POLLRDHUP
// always close on ret != 0?
-
+
if(0 != ret)
{
glob_opt.streams_opened -= connections[i]->streams_opened;
@@ -1106,7 +1106,7 @@
void
spdy_run_select(fd_set * read_fd_set,
- fd_set * write_fd_set,
+ fd_set * write_fd_set,
fd_set * except_fd_set,
struct SPDY_Connection *connections[],
int size)
@@ -1113,7 +1113,7 @@
{
int i;
int ret;
-
+
for(i=0; i<size; ++i)
{
// PRINT_INFO2("exec about to be called for %s", connections[i]->host);
@@ -1121,7 +1121,7 @@
{
//raise(SIGINT);
ret = spdy_exec_io(connections[i]);
-
+
if(0 != ret)
{
glob_opt.streams_opened -= connections[i]->streams_opened;
Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h 2015-08-02 14:48:32 UTC (rev
36163)
+++ libmicrohttpd/src/include/microhttpd.h 2015-08-02 17:11:48 UTC (rev
36164)
@@ -130,7 +130,7 @@
* Current version of the library.
* 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00094206
+#define MHD_VERSION 0x00094207
/**
* MHD-internal return code for "YES".
Modified: libmicrohttpd/src/include/platform_interface.h
===================================================================
--- libmicrohttpd/src/include/platform_interface.h 2015-08-02 14:48:32 UTC
(rev 36163)
+++ libmicrohttpd/src/include/platform_interface.h 2015-08-02 17:11:48 UTC
(rev 36164)
@@ -31,8 +31,8 @@
#include "w32functions.h"
#endif
-/* *****************************
- General function mapping
+/* *****************************
+ General function mapping
*****************************/
#if !defined(_WIN32) || defined(__CYGWIN__)
/**
@@ -80,15 +80,25 @@
#endif
-
-/* MHD_socket_close_(fd) close any FDs (non-W32) / close only socket FDs (W32)
*/
+/**
+ * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket
+ * FDs (W32). Note that on HP-UNIX, this function may leak the FD if
+ * errno is set to EINTR. Do not use HP-UNIX.
+ *
+ * @param fd descriptor to close
+ * @return 0 on success (error codes like EINTR and EIO are counted as success,
+ * only EBADF counts as an error!)
+ */
#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_socket_close_(fd) close((fd))
+#define MHD_socket_close_(fd) (((0 != close(fd)) && (EBADF == errno)) ? -1 : 0)
#else
#define MHD_socket_close_(fd) closesocket((fd))
#endif
-/* MHD_socket_errno_ is errno of last function (non-W32) / errno of last
socket function (W32) */
+/**
+ * MHD_socket_errno_ is errno of last function (non-W32) / errno of
+ * last socket function (W32)
+ */
#if !defined(MHD_WINSOCK_SOCKETS)
#define MHD_socket_errno_ errno
#else
Modified: libmicrohttpd/src/microspdy/daemon.c
===================================================================
--- libmicrohttpd/src/microspdy/daemon.c 2015-08-02 14:48:32 UTC (rev
36163)
+++ libmicrohttpd/src/microspdy/daemon.c 2015-08-02 17:11:48 UTC (rev
36164)
@@ -21,7 +21,7 @@
* @brief daemon functionality
* @author Andrey Uzunov
*/
-
+
#include "platform.h"
#include "structures.h"
#include "internal.h"
@@ -38,7 +38,7 @@
* @param line line number with the problem
* @param reason error message with details
*/
-static void
+static void
spdyf_panic_std (void *cls,
const char *file,
unsigned int line,
@@ -74,13 +74,13 @@
spdyf_cleanup_sessions (struct SPDY_Daemon *daemon)
{
struct SPDY_Session *session;
-
+
while (NULL != (session = daemon->cleanup_head))
{
DLL_remove (daemon->cleanup_head,
daemon->cleanup_tail,
session);
-
+
SPDYF_session_destroy(session);
}
}
@@ -95,9 +95,9 @@
spdyf_close_all_sessions (struct SPDY_Daemon *daemon)
{
struct SPDY_Session *session;
-
+
while (NULL != (session = daemon->sessions_head))
- {
+ {
//prepare GOAWAY frame
SPDYF_prepare_goaway(session, SPDY_GOAWAY_STATUS_OK, true);
//try to send the frame (it is best effort, so it will maybe
sent)
@@ -104,7 +104,7 @@
SPDYF_session_write(session,true);
SPDYF_session_close(session);
}
-
+
spdyf_cleanup_sessions(daemon);
}
@@ -111,7 +111,7 @@
/**
* Parse a list of options given as varargs.
- *
+ *
* @param daemon the daemon to initialize
* @param valist the options
* @return SPDY_YES on success, SPDY_NO on error
@@ -130,7 +130,7 @@
return SPDY_NO;
}
daemon->options |= opt;
-
+
switch (opt)
{
case SPDY_DAEMON_OPTION_SESSION_TIMEOUT:
@@ -157,7 +157,7 @@
}
-void
+void
SPDY_set_panic_func (SPDY_PanicCallback cb,
void *cls)
{
@@ -204,10 +204,10 @@
SPDYF_DEBUG("parse");
goto free_and_fail;
}
-
+
if(0 == daemon->max_num_frames)
daemon->max_num_frames = SPDYF_NUM_SENT_FRAMES_AT_ONCE;
-
+
if(!port && NULL == daemon->address)
{
SPDYF_DEBUG("Port is 0");
@@ -215,10 +215,10 @@
}
if(0 == daemon->io_subsystem)
daemon->io_subsystem = SPDY_IO_SUBSYSTEM_OPENSSL;
-
+
if(SPDY_YES != SPDYF_io_set_daemon(daemon, daemon->io_subsystem))
goto free_and_fail;
-
+
if(SPDY_IO_SUBSYSTEM_RAW != daemon->io_subsystem)
{
if (NULL == certfile
@@ -234,7 +234,7 @@
goto free_and_fail;
}
}
-
+
daemon->new_session_cb = nscb;
daemon->session_closed_cb = sccb;
daemon->new_request_cb = nrcb;
@@ -252,11 +252,11 @@
SPDYF_DEBUG("SPDY_DAEMON_FLAG_ONLY_IPV6 set but IPv4 address
provided");
goto free_and_fail;
}
-
+
addrlen = sizeof (struct sockaddr_in6);
-
+
if(NULL == daemon->address)
- {
+ {
if (NULL == (servaddr6 = malloc (addrlen)))
{
SPDYF_DEBUG("malloc");
@@ -268,7 +268,7 @@
servaddr6->sin6_port = htons (port);
daemon->address = (struct sockaddr *) servaddr6;
}
-
+
if(AF_INET6 == daemon->address->sa_family)
{
afamily = PF_INET6;
@@ -284,11 +284,11 @@
SPDYF_DEBUG("SPDY_DAEMON_FLAG_ONLY_IPV6 set but no support");
goto free_and_fail;
}
-
+
addrlen = sizeof (struct sockaddr_in);
-
+
if(NULL == daemon->address)
- {
+ {
if (NULL == (servaddr4 = malloc (addrlen)))
{
SPDYF_DEBUG("malloc");
@@ -300,9 +300,9 @@
servaddr4->sin_port = htons (port);
daemon->address = (struct sockaddr *) servaddr4;
}
-
+
afamily = PF_INET;
-#endif
+#endif
daemon->socket_fd = socket (afamily, SOCK_STREAM, 0);
if (-1 == daemon->socket_fd)
@@ -317,7 +317,7 @@
{
SPDYF_DEBUG("WARNING: SO_REUSEADDR was not set for the server");
}
-
+
#if HAVE_INET6
if(daemon->flags & SPDY_DAEMON_FLAG_ONLY_IPV6)
{
@@ -329,7 +329,7 @@
}
}
#endif
-
+
if (-1 == bind (daemon->socket_fd, daemon->address, addrlen))
{
SPDYF_DEBUG("bind %i",errno);
@@ -353,8 +353,8 @@
//for GOTO
free_and_fail:
if(daemon->socket_fd > 0)
- (void)close (daemon->socket_fd);
-
+ (void)MHD_socket_close_ (daemon->socket_fd);
+
free(servaddr4);
#if HAVE_INET6
free(servaddr6);
@@ -364,32 +364,32 @@
if(NULL != daemon->keyfile)
free(daemon->keyfile);
free (daemon);
-
+
return NULL;
}
-void
+void
SPDYF_stop_daemon (struct SPDY_Daemon *daemon)
{
daemon->fio_deinit(daemon);
-
+
shutdown (daemon->socket_fd, SHUT_RDWR);
spdyf_close_all_sessions (daemon);
- (void)close (daemon->socket_fd);
-
+ (void)MHD_socket_close_ (daemon->socket_fd);
+
if(!(SPDY_DAEMON_OPTION_SOCK_ADDR & daemon->options))
free(daemon->address);
-
+
free(daemon->certfile);
free(daemon->keyfile);
-
+
free(daemon);
}
int
-SPDYF_get_timeout (struct SPDY_Daemon *daemon,
+SPDYF_get_timeout (struct SPDY_Daemon *daemon,
unsigned long long *timeout)
{
unsigned long long earliest_deadline = 0;
@@ -396,7 +396,7 @@
unsigned long long now;
struct SPDY_Session *pos;
bool have_timeout;
-
+
if(0 == daemon->session_timeout)
return SPDY_NO;
@@ -409,7 +409,7 @@
earliest_deadline = pos->last_activity +
daemon->session_timeout;
have_timeout = true;
-
+
if (SPDY_YES == pos->fio_is_pending(pos))
{
earliest_deadline = 0;
@@ -416,7 +416,7 @@
break;
}
}
-
+
if (!have_timeout)
return SPDY_NO;
if (earliest_deadline <= now)
@@ -423,7 +423,7 @@
*timeout = 0;
else
*timeout = earliest_deadline - now;
-
+
return SPDY_YES;
}
@@ -431,7 +431,7 @@
int
SPDYF_get_fdset (struct SPDY_Daemon *daemon,
fd_set *read_fd_set,
- fd_set *write_fd_set,
+ fd_set *write_fd_set,
fd_set *except_fd_set,
bool all)
{
@@ -470,7 +470,7 @@
}
-void
+void
SPDYF_run (struct SPDY_Daemon *daemon)
{
struct SPDY_Session *pos;
@@ -512,7 +512,7 @@
if (FD_ISSET (ds, &rs) || pos->fio_is_pending(pos)){
SPDYF_session_read(pos);
}
-
+
//do something with the data in read buffer
if(SPDY_NO == SPDYF_session_idle(pos))
{
@@ -519,7 +519,7 @@
//the session was closed, cannot write anymore
//continue;
}
-
+
//write whatever has been put to the response queue
//during read or idle operation, something might be put
//on the response queue, thus call write operation
@@ -530,7 +530,7 @@
//continue;
}
}
-
+
/* the response queue has been flushed for half closed
* connections, so let close them */
/*if(pos->read_closed)
@@ -539,6 +539,6 @@
}*/
}
}
-
+
spdyf_cleanup_sessions(daemon);
}
Modified: libmicrohttpd/src/microspdy/internal.h
===================================================================
--- libmicrohttpd/src/microspdy/internal.h 2015-08-02 14:48:32 UTC (rev
36163)
+++ libmicrohttpd/src/microspdy/internal.h 2015-08-02 17:11:48 UTC (rev
36164)
@@ -26,6 +26,7 @@
#define INTERNAL_H_H
#include "platform.h"
+#include "platform_interface.h"
#include "microspdy.h"
/**
@@ -63,7 +64,7 @@
/**
* Trigger 'panic' action based on fatal errors.
- *
+ *
* @param msg error message (const char *)
*/
#define SPDYF_PANIC(msg) \
@@ -103,7 +104,7 @@
*
* @param n input value (int32_t)
* @return converted value (uint32_t)
- */
+ */
#if HAVE_BIG_ENDIAN
#define NTOH24(n) n
#else
Modified: libmicrohttpd/src/microspdy/session.c
===================================================================
--- libmicrohttpd/src/microspdy/session.c 2015-08-02 14:48:32 UTC (rev
36163)
+++ libmicrohttpd/src/microspdy/session.c 2015-08-02 17:11:48 UTC (rev
36164)
@@ -1476,7 +1476,7 @@
free_and_fail:
/* something failed, so shutdown, close and free memory */
shutdown (new_socket_fd, SHUT_RDWR);
- (void)close (new_socket_fd);
+ (void)MHD_socket_close_ (new_socket_fd);
if(NULL != session)
{
@@ -1577,7 +1577,7 @@
struct SPDYF_Stream *stream;
struct SPDYF_Response_Queue *response_queue;
- (void)close (session->socket_fd);
+ (void)MHD_socket_close_ (session->socket_fd);
SPDYF_zlib_deflate_end(&session->zlib_send_stream);
SPDYF_zlib_inflate_end(&session->zlib_recv_stream);
Modified: libmicrohttpd/src/testcurl/https/test_https_time_out.c
===================================================================
--- libmicrohttpd/src/testcurl/https/test_https_time_out.c 2015-08-02
14:48:32 UTC (rev 36163)
+++ libmicrohttpd/src/testcurl/https/test_https_time_out.c 2015-08-02
17:11:48 UTC (rev 36164)
@@ -19,7 +19,7 @@
*/
/**
- * @file mhds_get_test.c
+ * @file test_https_time_out.c
* @brief: daemon TLS alert response test-case
*
* @author Sagie Amir
@@ -69,7 +69,7 @@
if (ret < 0)
{
fprintf (stderr, "Error: %s\n", MHD_E_FAILED_TO_CONNECT);
- close (sd);
+ MHD_socket_close_ (sd);
return -1;
}
@@ -77,7 +77,7 @@
if (ret < 0)
{
fprintf (stderr, "Handshake failed\n");
- close (sd);
+ MHD_socket_close_ (sd);
return -1;
}
@@ -88,11 +88,11 @@
if (send (sd, "", 1, 0) == 0)
{
fprintf (stderr, "Connection failed to time-out\n");
- close (sd);
+ MHD_socket_close_ (sd);
return -1;
}
- close (sd);
+ MHD_socket_close_ (sd);
return 0;
}
@@ -123,7 +123,7 @@
MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
MHD_OPTION_END);
- if (d == NULL)
+ if (NULL == d)
{
fprintf (stderr, MHD_E_SERVER_INIT);
return -1;
Modified: libmicrohttpd/src/testcurl/https/test_tls_extensions.c
===================================================================
--- libmicrohttpd/src/testcurl/https/test_tls_extensions.c 2015-08-02
14:48:32 UTC (rev 36163)
+++ libmicrohttpd/src/testcurl/https/test_tls_extensions.c 2015-08-02
17:11:48 UTC (rev 36164)
@@ -188,8 +188,8 @@
}
cleanup:
- if (sd != -1)
- close (sd);
+ if (-1 != sd)
+ MHD_socket_close_ (sd);
gnutls_free (cbc.buf);
return ret;
}
@@ -206,7 +206,7 @@
gnutls_datum_t cert;
gnutls_certificate_credentials_t xcred;
- const int ext_arr[] = {
+ const int ext_arr[] = {
GNUTLS_EXTENSION_SERVER_NAME,
-1
};
Modified: libmicrohttpd/src/testspdy/test_new_connection.c
===================================================================
--- libmicrohttpd/src/testspdy/test_new_connection.c 2015-08-02 14:48:32 UTC
(rev 36163)
+++ libmicrohttpd/src/testspdy/test_new_connection.c 2015-08-02 17:11:48 UTC
(rev 36164)
@@ -17,7 +17,7 @@
*/
/**
- * @file request_response.c
+ * @file test_new_connection.c
* @brief tests new connection callback. spdycli.c
* code is reused here
* @author Andrey Uzunov
@@ -537,7 +537,7 @@
if(rv == 0) {
break;
}
- close(fd);
+ MHD_socket_close_(fd);
fd = -1;
}
freeaddrinfo(res);
@@ -650,7 +650,8 @@
/*
* Fetches the resource denoted by |uri|.
*/
-static void fetch_uri(const struct URI *uri)
+static void
+fetch_uri(const struct URI *uri)
{
spdylay_session_callbacks callbacks;
int fd;
@@ -726,11 +727,13 @@
SSL_free(ssl);
SSL_CTX_free(ssl_ctx);
shutdown(fd, SHUT_WR);
- close(fd);
+ MHD_socket_close_ (fd);
request_free(&req);
}
-static int parse_uri(struct URI *res, const char *uri)
+
+static int
+parse_uri(struct URI *res, const char *uri)
{
/* We only interested in https */
size_t len, i, offset;
Modified: libmicrohttpd/src/testspdy/test_notls.c
===================================================================
--- libmicrohttpd/src/testspdy/test_notls.c 2015-08-02 14:48:32 UTC (rev
36163)
+++ libmicrohttpd/src/testspdy/test_notls.c 2015-08-02 17:11:48 UTC (rev
36164)
@@ -488,7 +488,7 @@
if(rv == 0) {
break;
}
- close(fd);
+ MHD_socket_close_(fd);
fd = -1;
dief("connect", strerror(errno));
}
@@ -661,7 +661,7 @@
/* Resource cleanup */
spdylay_session_del(connection.session);
shutdown(fd, SHUT_WR);
- close(fd);
+ MHD_socket_close_(fd);
request_free(&req);
}
Modified: libmicrohttpd/src/testspdy/test_request_response.c
===================================================================
--- libmicrohttpd/src/testspdy/test_request_response.c 2015-08-02 14:48:32 UTC
(rev 36163)
+++ libmicrohttpd/src/testspdy/test_request_response.c 2015-08-02 17:11:48 UTC
(rev 36164)
@@ -17,7 +17,7 @@
*/
/**
- * @file request_response.c
+ * @file test_request_response.c
* @brief tests receiving request and sending response. spdycli.c (spdylay)
* code is reused here
* @author Andrey Uzunov
@@ -525,7 +525,7 @@
if(rv == 0) {
break;
}
- close(fd);
+ MHD_socket_close_(fd);
fd = -1;
}
freeaddrinfo(res);
@@ -714,7 +714,7 @@
SSL_free(ssl);
SSL_CTX_free(ssl_ctx);
shutdown(fd, SHUT_WR);
- close(fd);
+ MHD_socket_close_(fd);
request_free(&req);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36164 - in libmicrohttpd: . src/examples src/include src/microspdy src/testcurl/https src/testspdy,
gnunet <=