[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28427 - in libmicrohttpd/src: examples include microhttpd
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28427 - in libmicrohttpd/src: examples include microhttpd microspdy spdy2http testspdy |
Date: |
Wed, 7 Aug 2013 08:41:45 +0200 |
Author: grothoff
Date: 2013-08-07 08:41:45 +0200 (Wed, 07 Aug 2013)
New Revision: 28427
Modified:
libmicrohttpd/src/examples/Makefile.am
libmicrohttpd/src/include/platform.h
libmicrohttpd/src/microhttpd/connection.c
libmicrohttpd/src/microhttpd/daemon.c
libmicrohttpd/src/microhttpd/memorypool.c
libmicrohttpd/src/microspdy/Makefile.am
libmicrohttpd/src/spdy2http/Makefile.am
libmicrohttpd/src/testspdy/Makefile.am
Log:
Part 2 of 2 - Remove and replace PlibC macros with native function calls.
Modified: libmicrohttpd/src/examples/Makefile.am
===================================================================
--- libmicrohttpd/src/examples/Makefile.am 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/examples/Makefile.am 2013-08-07 06:41:45 UTC (rev
28427)
@@ -60,7 +60,7 @@
endif
if HAVE_W32
-AM_CFLAGS = -DWINDOWS
+AM_CFLAGS += -DWINDOWS
endif
minimal_example_SOURCES = \
Modified: libmicrohttpd/src/include/platform.h
===================================================================
--- libmicrohttpd/src/include/platform.h 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/include/platform.h 2013-08-07 06:41:45 UTC (rev
28427)
@@ -109,7 +109,32 @@
#include <arpa/inet.h>
#endif
-#include <plibc.h>
+#ifndef WINDOWS
+#define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_STR "/"
+#define PATH_SEPARATOR ':'
+#define PATH_SEPARATOR_STR ":"
+#define NEWLINE "\n"
+#else /* ifndef WINDOWS */
+
+#include <ws2tcpip.h>
+#include <windows.h>
+
+#define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR_STR "\\"
+#define PATH_SEPARATOR ';'
+#define PATH_SEPARATOR_STR ";"
+#define NEWLINE "\r\n"
+
+#define SHUT_WR SD_SEND
+#define SHUT_RD SD_RECEIVE
+#define SHUT_RDWR SD_BOTH
+
+#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
+
+#endif /* ifndef WINDOWS */
+
+
#endif
Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/microhttpd/connection.c 2013-08-07 06:41:45 UTC (rev
28427)
@@ -262,7 +262,7 @@
daemon = connection->daemon;
if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
- SHUTDOWN (connection->socket_fd,
+ shutdown (connection->socket_fd,
(MHD_YES == connection->read_closed) ? SHUT_WR : SHUT_RDWR);
connection->state = MHD_CONNECTION_CLOSED;
connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
@@ -566,7 +566,7 @@
Note that the change from 'SHOULD NOT' to 'MUST NOT' is
a recent development of the HTTP 1.1 specification.
*/
- SPRINTF (buf,
+ sprintf (buf,
MHD_UNSIGNED_LONG_LONG_PRINTF,
(MHD_UNSIGNED_LONG_LONG) connection->response->total_size);
MHD_add_response_header (connection->response,
@@ -598,15 +598,19 @@
time_t t;
time (&t);
+#ifndef WINDOWS
gmtime_r (&t, &now);
- SPRINTF (date,
+#else
+ gmtime_s (&now, &t);
+#endif
+ sprintf (date,
"Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
days[now.tm_wday % 7],
(unsigned int) now.tm_mday,
mons[now.tm_mon % 12],
(unsigned int) (1900 + now.tm_year),
- (unsigned int) now.tm_hour,
- (unsigned int) now.tm_min,
+ (unsigned int) now.tm_hour,
+ (unsigned int) now.tm_min,
(unsigned int) now.tm_sec);
}
@@ -681,21 +685,21 @@
add_extra_headers (connection);
rc = connection->responseCode & (~MHD_ICY_FLAG);
reason_phrase = MHD_get_reason_phrase_for (rc);
- SPRINTF (code,
+ sprintf (code,
"%s %u %s\r\n",
(0 != (connection->responseCode & MHD_ICY_FLAG))
- ? "ICY"
+ ? "ICY"
: ( (0 == strcasecmp (MHD_HTTP_VERSION_1_0,
- connection->version))
- ? MHD_HTTP_VERSION_1_0
+ connection->version))
+ ? MHD_HTTP_VERSION_1_0
: MHD_HTTP_VERSION_1_1),
- rc,
+ rc,
reason_phrase);
off = strlen (code);
/* estimate size */
size = off + 2; /* extra \r\n at the end */
kind = MHD_HEADER_KIND;
- if ( (0 == (connection->daemon->options & MHD_SUPPRESS_DATE_NO_CLOCK))
&&
+ if ( (0 == (connection->daemon->options & MHD_SUPPRESS_DATE_NO_CLOCK)) &&
(NULL == MHD_get_response_header (connection->response,
MHD_HTTP_HEADER_DATE)) )
get_date_string (date);
@@ -745,9 +749,9 @@
}
for (pos = connection->response->first_header; NULL != pos; pos = pos->next)
if (pos->kind == kind)
- off += SPRINTF (&data[off],
+ off += sprintf (&data[off],
"%s: %s\r\n",
- pos->header,
+ pos->header,
pos->value);
if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED)
{
@@ -1507,9 +1511,9 @@
"Failed to receive data: %s\n",
gnutls_strerror (bytes_read));
else
-#endif
+#endif
MHD_DLOG (connection->daemon,
- "Failed to receive data: %s\n", STRERROR (errno));
+ "Failed to receive data: %s\n", strerror (errno));
#endif
CONNECTION_CLOSE_ERROR (connection, NULL);
return MHD_YES;
@@ -1520,7 +1524,7 @@
connection->read_closed = MHD_YES;
/* shutdown is not required here, as the other side already
knows; so flagging this internally should suffice */
- /* SHUTDOWN (connection->socket_fd, SHUT_RD); */
+ /* shutdown (connection->socket_fd, SHUT_RD); */
return MHD_YES;
}
connection->read_buffer_offset += bytes_read;
@@ -1556,9 +1560,9 @@
"Failed to send data: %s\n",
gnutls_strerror (ret));
else
-#endif
+#endif
MHD_DLOG (connection->daemon,
- "Failed to send data: %s\n", STRERROR (errno));
+ "Failed to send data: %s\n", strerror (errno));
#endif
CONNECTION_CLOSE_ERROR (connection, NULL);
return MHD_YES;
@@ -1914,7 +1918,7 @@
break;
#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
- "Failed to send data: %s\n", STRERROR (errno));
+ "Failed to send data: %s\n", strerror (errno));
#endif
CONNECTION_CLOSE_ERROR (connection, NULL);
return MHD_YES;
@@ -1976,7 +1980,7 @@
return MHD_YES;
#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
- "Failed to send data: %s\n", STRERROR (errno));
+ "Failed to send data: %s\n", strerror (errno));
#endif
CONNECTION_CLOSE_ERROR (connection, NULL);
return MHD_YES;
@@ -2527,7 +2531,7 @@
if (0 != (daemon->options & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to epoll_ctl failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
connection->state = MHD_CONNECTION_CLOSED;
cleanup_connection (connection);
@@ -2686,7 +2690,7 @@
refuse to read body / footers or further
requests! */
if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
- (void) SHUTDOWN (connection->socket_fd, SHUT_RD);
+ (void) shutdown (connection->socket_fd, SHUT_RD);
connection->read_closed = MHD_YES;
connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
}
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/microhttpd/daemon.c 2013-08-07 06:41:45 UTC (rev
28427)
@@ -294,14 +294,14 @@
MHD_ip_count_lock (daemon);
/* Search for the IP address */
- if (NULL == (nodep = TSEARCH (key,
- &daemon->per_ip_connection_count,
+ if (NULL == (nodep = tsearch (key,
+ &daemon->per_ip_connection_count,
&MHD_ip_addr_compare)))
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Failed to add IP connection count node\n");
-#endif
+#endif
MHD_ip_count_unlock (daemon);
free (key);
return MHD_NO;
@@ -350,10 +350,10 @@
MHD_ip_count_lock (daemon);
/* Search for the IP address */
- if (NULL == (nodep = TFIND (&search_key,
- &daemon->per_ip_connection_count,
+ if (NULL == (nodep = tfind (&search_key,
+ &daemon->per_ip_connection_count,
&MHD_ip_addr_compare)))
- {
+ {
/* Something's wrong if we couldn't find an IP address
* that was previously added */
MHD_PANIC ("Failed to find previously-added IP address\n");
@@ -367,8 +367,8 @@
/* Remove the node entirely if count reduces to 0 */
if (0 == --found_key->count)
{
- TDELETE (found_key,
- &daemon->per_ip_connection_count,
+ tdelete (found_key,
+ &daemon->per_ip_connection_count,
&MHD_ip_addr_compare);
free (found_key);
}
@@ -696,7 +696,7 @@
/* how did we get here!? */
goto exit;
}
- num_ready = SELECT (max + 1, &rs, &ws, NULL, tvp);
+ num_ready = select (max + 1, &rs, &ws, NULL, tvp);
if (num_ready < 0)
{
if (EINTR == errno)
@@ -705,7 +705,7 @@
MHD_DLOG (con->daemon,
"Error during select (%d): `%s'\n",
max,
- STRERROR (errno));
+ strerror (errno));
#endif
break;
}
@@ -751,7 +751,7 @@
continue;
#if HAVE_MESSAGES
MHD_DLOG (con->daemon, "Error during poll: `%s'\n",
- STRERROR (errno));
+ strerror (errno));
#endif
break;
}
@@ -814,7 +814,7 @@
errno = ENOTCONN;
return -1;
}
- ret = RECV (connection->socket_fd, other, i, MSG_NOSIGNAL);
+ ret = recv (connection->socket_fd, other, i, MSG_NOSIGNAL);
#if EPOLL_SUPPORT
if (ret < (ssize_t) i)
{
@@ -853,7 +853,7 @@
return -1;
}
if (0 != (connection->daemon->options & MHD_USE_SSL))
- return SEND (connection->socket_fd, other, i, MSG_NOSIGNAL);
+ return send (connection->socket_fd, other, i, MSG_NOSIGNAL);
#if LINUX
if ( (connection->write_buffer_append_offset ==
connection->write_buffer_send_offset) &&
@@ -889,7 +889,7 @@
http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html
*/
}
#endif
- ret = SEND (connection->socket_fd, other, i, MSG_NOSIGNAL);
+ ret = send (connection->socket_fd, other, i, MSG_NOSIGNAL);
#if EPOLL_SUPPORT
if (ret < (ssize_t) i)
{
@@ -1009,7 +1009,7 @@
client_socket,
addr, addrlen);
/* all pools are at their connection limit, must refuse */
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
return MHD_NO;
}
@@ -1024,7 +1024,7 @@
client_socket,
FD_SETSIZE);
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
return MHD_NO;
}
@@ -1044,7 +1044,7 @@
MHD_DLOG (daemon,
"Server reached connection limit (closing inbound
connection)\n");
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
return MHD_NO;
}
@@ -1059,7 +1059,7 @@
MHD_DLOG (daemon, "Connection rejected, closing connection\n");
#endif
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
return MHD_NO;
@@ -1080,9 +1080,9 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Error allocating memory: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
return MHD_NO;
@@ -1094,9 +1094,9 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Error allocating memory: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
free (connection);
@@ -1109,9 +1109,9 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Error allocating memory: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
MHD_pool_destroy (connection->pool);
@@ -1149,7 +1149,7 @@
MHD_DLOG (daemon,
"Failed to make socket %d non-blocking: %s\n",
connection->socket_fd,
- STRERROR (errno));
+ strerror (errno));
#endif
}
#else
@@ -1159,7 +1159,7 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Failed to make socket non-blocking: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
}
#endif
@@ -1190,7 +1190,7 @@
"Failed to setup TLS credentials: unknown credential type
%d\n",
daemon->cred_type);
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
free (connection->addr);
@@ -1233,7 +1233,7 @@
{
#if HAVE_MESSAGES
MHD_DLOG (daemon, "Failed to create a thread: %s\n",
- STRERROR (res_thread_create));
+ strerror (res_thread_create));
#endif
goto cleanup;
}
@@ -1256,7 +1256,7 @@
if (0 != (daemon->options & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to epoll_ctl failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
goto cleanup;
}
@@ -1276,7 +1276,7 @@
return MHD_YES;
#if HTTPS_SUPPORT || EPOLL_SUPPORT
cleanup:
- if (0 != CLOSE (client_socket))
+ if (0 != close (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
@@ -1321,6 +1321,9 @@
#endif
struct sockaddr *addr = (struct sockaddr *) &addrstorage;
socklen_t addrlen;
+#ifdef WINDOWS
+ LPVOID msgBuffer;
+#endif
int s;
int fd;
int nonblock;
@@ -1341,20 +1344,37 @@
#if HAVE_ACCEPT4
s = accept4 (fd, addr, &addrlen, SOCK_CLOEXEC | nonblock);
#else
- s = ACCEPT (fd, addr, &addrlen);
+ s = accept (fd, addr, &addrlen);
#endif
if ((-1 == s) || (addrlen <= 0))
{
#if HAVE_MESSAGES
/* This could be a common occurance with multiple worker threads */
if ((EAGAIN != errno) && (EWOULDBLOCK != errno))
+ {
+#ifndef WINDOWS
MHD_DLOG (daemon,
"Error accepting connection: %s\n",
- STRERROR (errno));
+ strerror (errno));
+#else
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ (DWORD) GetLastError (),
+ MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &msgBuffer,
+ 0, NULL);
+ MHD_DLOG (daemon,
+ "Error accepting connection: %s\n",
+ msgBuffer);
+ LocalFree (msgBuffer);
#endif
+#endif
+ }
if (-1 != s)
{
- if (0 != CLOSE (s))
+ if (0 != close (s))
MHD_PANIC ("close failed\n");
/* just in case */
}
@@ -1370,9 +1390,9 @@
if (0 != ioctlsocket (s, FIONBIO, &flags))
{
#if HAVE_MESSAGES
- MHD_DLOG (daemon,
- "Failed to make socket non-blocking: %s\n",
- STRERROR (errno));
+ MHD_DLOG (daemon,
+ "Failed to make socket non-blocking: %s\n",
+ strerror (errno));
#endif
}
if (!GetHandleInformation ((HANDLE) s, &dwFlags) ||
@@ -1380,10 +1400,18 @@
!SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0)))
{
#if HAVE_MESSAGES
- SetErrnoFromWinError (GetLastError ());
- MHD_DLOG (daemon,
- "Failed to make socket non-inheritable: %s\n",
- STRERROR (errno));
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ (DWORD) GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &msgBuffer,
+ 0, NULL );
+ MHD_DLOG (daemon,
+ "Error accepting connection: %s\n",
+ msgBuffer);
+ LocalFree(msgBuffer);
#endif
}
#else
@@ -1401,8 +1429,8 @@
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
- "Failed to make socket non-inheritable: %s\n",
- STRERROR (errno));
+ "Failed to make socket non-inheritable: %s\n",
+ strerror (errno));
#endif
}
#endif
@@ -1485,7 +1513,7 @@
pos->response = NULL;
}
if ( (-1 != pos->socket_fd) &&
- (0 != CLOSE (pos->socket_fd)) )
+ (0 != close (pos->socket_fd)) )
MHD_PANIC ("close failed\n");
if (NULL != pos->addr)
free (pos->addr);
@@ -1690,7 +1718,14 @@
struct timeval timeout;
struct timeval *tv;
MHD_UNSIGNED_LONG_LONG ltimeout;
+#ifdef WINDOWS
+ LPVOID msgBuffer;
+ DWORD dwBytes;
+#endif
+#ifdef WINDOWS
+loop_select:
+#endif
timeout.tv_sec = 0;
timeout.tv_usec = 0;
if (MHD_YES == daemon->shutdown)
@@ -1707,19 +1742,20 @@
/* If we're at the connection limit, no need to
accept new connections. */
- if ( (0 == daemon->max_connections) &&
+ if ( (0 == daemon->max_connections) &&
(-1 != daemon->socket_fd) )
FD_CLR (daemon->socket_fd, &rs);
}
else
{
/* accept only, have one thread per connection */
- if (-1 != daemon->socket_fd)
+ if (-1 != daemon->socket_fd)
{
max = daemon->socket_fd;
FD_SET (daemon->socket_fd, &rs);
}
}
+#ifndef WINDOWS
if (-1 != daemon->wpipe[0])
{
FD_SET (daemon->wpipe[0], &rs);
@@ -1727,12 +1763,18 @@
if (max < daemon->wpipe[0])
max = daemon->wpipe[0];
}
+#endif
tv = NULL;
if (MHD_NO == may_block)
{
+#ifndef WINDOWS
timeout.tv_usec = 0;
+#else
+ timeout.tv_usec = 100000;
+#endif
timeout.tv_sec = 0;
+
tv = &timeout;
}
else if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
@@ -1745,7 +1787,15 @@
}
if (-1 == max)
return MHD_YES;
- num_ready = SELECT (max + 1, &rs, &ws, &es, tv);
+#ifdef WINDOWS
+ if (tv == NULL)
+ {
+ timeout.tv_usec = 100000;
+ timeout.tv_sec = 0;
+ tv = &timeout;
+ }
+#endif
+ num_ready = select (max + 1, &rs, &ws, &es, tv);
if (MHD_YES == daemon->shutdown)
return MHD_NO;
if (num_ready < 0)
@@ -1753,10 +1803,41 @@
if (EINTR == errno)
return MHD_YES;
#if HAVE_MESSAGES
- MHD_DLOG (daemon, "select failed: %s\n", STRERROR (errno));
+#ifndef WINDOWS
+ MHD_DLOG (daemon, "select failed: %s\n", strerror (errno));
+#else
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ (DWORD) GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &msgBuffer,
+ 0, NULL);
+ MHD_DLOG (daemon, "select failed: %s\n", msgBuffer);
+ LocalFree(msgBuffer);
#endif
+#endif
return MHD_NO;
}
+#ifdef WINDOWS
+ if (num_ready == 0) {
+ if (-1 != daemon->wpipe[0])
+ {
+ if (! PeekNamedPipe((HANDLE) daemon->wpipe[0], NULL, 0, NULL,
&dwBytes, NULL))
+ {
+ goto loop_select;
+ }
+ else if (dwBytes)
+ FD_SET (daemon->wpipe[0], &rs);
+ else
+ goto loop_select;
+ }
+ else
+ goto loop_select;
+ }
+#endif
+
return MHD_run_from_select (daemon, &rs, &ws, &es);
}
@@ -1850,7 +1931,7 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"poll failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
return MHD_NO;
}
@@ -1950,7 +2031,7 @@
if (EINTR == errno)
return MHD_YES;
#if HAVE_MESSAGES
- MHD_DLOG (daemon, "poll failed: %s\n", STRERROR (errno));
+ MHD_DLOG (daemon, "poll failed: %s\n", strerror (errno));
#endif
return MHD_NO;
}
@@ -2043,7 +2124,7 @@
if (0 != (daemon->options & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to epoll_ctl failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
return MHD_NO;
}
@@ -2095,7 +2176,7 @@
if (0 != (daemon->options & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to epoll_wait failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
return MHD_NO;
}
@@ -2681,19 +2762,19 @@
#ifdef WINDOWS
DWORD dwFlags;
#endif
-
+
/* use SOCK_STREAM rather than ai_socktype: some getaddrinfo
* implementations do not set ai_socktype, e.g. RHL6.2. */
- fd = SOCKET (domain, ctype, protocol);
+ fd = socket (domain, ctype, protocol);
if ( (-1 == fd) && (EINVAL == errno) && (0 != sock_cloexec) )
{
sock_cloexec = 0;
- fd = SOCKET(domain, type, protocol);
+ fd = socket(domain, type, protocol);
}
if (-1 == fd)
return -1;
if (0 != sock_cloexec)
- return fd; /* this is it */
+ return fd; /* this is it */
/* flag was not set during 'socket' call, let's try setting it manually */
#ifndef WINDOWS
flags = fcntl (fd, F_GETFD);
@@ -2702,9 +2783,6 @@
if (!GetHandleInformation ((HANDLE) fd, &dwFlags))
#endif
{
-#ifdef WINDOWS
- SetErrnoFromWinError (GetLastError ());
-#endif
return fd; /* good luck */
}
#ifndef WINDOWS
@@ -2718,9 +2796,6 @@
if (!SetHandleInformation ((HANDLE) fd, HANDLE_FLAG_INHERIT, 0))
#endif
{
-#ifdef WINDOWS
- SetErrnoFromWinError (GetLastError ());
-#endif
return fd; /* good luck */
}
return fd;
@@ -2747,7 +2822,7 @@
if (0 != (daemon->options & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to epoll_create1 failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
return MHD_NO;
}
@@ -2764,7 +2839,7 @@
if (0 != (daemon->options & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to epoll_ctl failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
return MHD_NO;
}
@@ -2812,15 +2887,15 @@
#ifndef HAVE_INET6
if (0 != (flags & MHD_USE_IPv6))
- return NULL;
+ return NULL;
#endif
#ifndef HAVE_POLL_H
if (0 != (flags & MHD_USE_POLL))
- return NULL;
+ return NULL;
#endif
#if ! HTTPS_SUPPORT
if (0 != (flags & MHD_USE_SSL))
- return NULL;
+ return NULL;
#endif
if (NULL == dh)
return NULL;
@@ -2865,12 +2940,17 @@
if (0 == (flags & (MHD_USE_SELECT_INTERNALLY |
MHD_USE_THREAD_PER_CONNECTION)))
use_pipe = 0; /* useless if we are using 'external' select */
if ( (use_pipe) &&
- (0 != PIPE (daemon->wpipe)) )
+#ifndef WINDOWS
+ (0 != pipe (daemon->wpipe)) )
+#else
+ (0 == CreatePipe ((HANDLE *) &daemon->wpipe[0],
+ (HANDLE *) &daemon->wpipe[1], NULL, 0)) )
+#endif
{
#if HAVE_MESSAGES
- MHD_DLOG (daemon,
+ MHD_DLOG (daemon,
"Failed to create control pipe: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
free (daemon);
return NULL;
@@ -2883,9 +2963,9 @@
MHD_DLOG (daemon,
"file descriptor for control pipe exceeds maximum value\n");
#endif
- if (0 != CLOSE (daemon->wpipe[0]))
+ if (0 != close (daemon->wpipe[0]))
MHD_PANIC ("close failed\n");
- if (0 != CLOSE (daemon->wpipe[1]))
+ if (0 != close (daemon->wpipe[1]))
MHD_PANIC ("close failed\n");
free (daemon);
return NULL;
@@ -2937,7 +3017,7 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Failed to allocate memory for nonce-nc map: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
#if HTTPS_SUPPORT
if (0 != (flags & MHD_USE_SSL))
@@ -3025,20 +3105,20 @@
if (0 != (flags & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Call to socket failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
goto free_and_fail;
}
- if ( (0 > SETSOCKOPT (socket_fd,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on, sizeof (on))) &&
+ if ( (setsockopt (socket_fd,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on, sizeof (on))) &&
(0 != (flags & MHD_USE_DEBUG)) )
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"setsockopt failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
}
@@ -3090,30 +3170,30 @@
#else
const char on = 1;
#endif
- if ( (0 > SETSOCKOPT (socket_fd,
- IPPROTO_IPV6, IPV6_V6ONLY,
- &on, sizeof (on))) &&
+ if ( (setsockopt (socket_fd,
+ IPPROTO_IPV6, IPV6_V6ONLY,
+ &on, sizeof (on))) &&
(0 != (flags & MHD_USE_DEBUG)) )
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"setsockopt failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
}
#endif
#endif
}
- if (-1 == BIND (socket_fd, servaddr, addrlen))
+ if (-1 == bind (socket_fd, servaddr, addrlen))
{
#if HAVE_MESSAGES
if (0 != (flags & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Failed to bind to port %u: %s\n",
(unsigned int) port,
- STRERROR (errno));
+ strerror (errno));
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != close (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3126,23 +3206,23 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Failed to make listen socket non-blocking: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != close (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
}
#endif
- if (LISTEN (socket_fd, 32) < 0)
+ if (listen (socket_fd, 32) < 0)
{
#if HAVE_MESSAGES
if (0 != (flags & MHD_USE_DEBUG))
MHD_DLOG (daemon,
"Failed to listen for connections: %s\n",
- STRERROR (errno));
+ strerror (errno));
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != close (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3162,7 +3242,7 @@
socket_fd,
FD_SETSIZE);
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != close (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3175,7 +3255,7 @@
"MHD failed to initialize IP connection limit mutex\n");
#endif
if ( (-1 != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != close (socket_fd)) )
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3187,7 +3267,7 @@
#endif
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
if ( (-1 != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != close (socket_fd)) )
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3201,7 +3281,7 @@
"Failed to initialize TLS support\n");
#endif
if ( (-1 != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != close (socket_fd)) )
MHD_PANIC ("close failed\n");
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
@@ -3218,12 +3298,12 @@
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Failed to create listen thread: %s\n",
- STRERROR (res_thread_create));
+ strerror (res_thread_create));
#endif
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
if ( (-1 != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != close (socket_fd)) )
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3257,14 +3337,8 @@
goto thread_failed;
#else
sk_flags = 1;
-#if HAVE_PLIBC_FD
- if (SOCKET_ERROR ==
- ioctlsocket (plibc_fd_get_handle (socket_fd), FIONBIO, &sk_flags))
- goto thread_failed;
-#else
if (ioctlsocket (socket_fd, FIONBIO, &sk_flags) == SOCKET_ERROR)
goto thread_failed;
-#endif // PLIBC_FD
#endif // MINGW
/* Allocate memory for pooled objects */
@@ -3314,8 +3388,8 @@
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
- "Failed to create pool thread: %s\n",
- STRERROR (res_thread_create));
+ "Failed to create pool thread: %s\n",
+ strerror (res_thread_create));
#endif
/* Free memory for this worker; cleanup below handles
* all previously-created workers. */
@@ -3334,7 +3408,7 @@
if (0 == i)
{
if ( (-1 != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != close (socket_fd)) )
MHD_PANIC ("close failed\n");
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
@@ -3422,7 +3496,7 @@
(0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )
MHD_PANIC ("Failed to acquire cleanup mutex\n");
for (pos = daemon->connections_head; NULL != pos; pos = pos->nextX)
- SHUTDOWN (pos->socket_fd,
+ shutdown (pos->socket_fd,
(pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
(0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) )
@@ -3509,7 +3583,7 @@
}
if (-1 != daemon->wpipe[1])
{
- if (1 != WRITE (daemon->wpipe[1], "e", 1))
+ if (1 != write (daemon->wpipe[1], "e", 1))
MHD_PANIC ("failed to signal shutdownn via pipe");
}
#ifdef HAVE_LISTEN_SHUTDOWN
@@ -3517,7 +3591,7 @@
{
/* fd might be -1 here due to 'MHD_quiesce_daemon' */
if (-1 != fd)
- (void) SHUTDOWN (fd, SHUT_RDWR);
+ (void) shutdown (fd, SHUT_RDWR);
}
#endif
#if EPOLL_SUPPORT
@@ -3546,7 +3620,7 @@
pthread_mutex_destroy
(&daemon->worker_pool[i].cleanup_connection_mutex);
#if EPOLL_SUPPORT
if ( (-1 != daemon->worker_pool[i].epoll_fd) &&
- (0 != CLOSE (daemon->worker_pool[i].epoll_fd)) )
+ (0 != close (daemon->worker_pool[i].epoll_fd)) )
MHD_PANIC ("close failed\n");
#endif
}
@@ -3567,7 +3641,7 @@
}
close_all_connections (daemon);
if ( (-1 != fd) &&
- (0 != CLOSE (fd)) )
+ (0 != close (fd)) )
MHD_PANIC ("close failed\n");
/* TLS clean up */
@@ -3582,7 +3656,7 @@
#if EPOLL_SUPPORT
if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) &&
(-1 != daemon->epoll_fd) &&
- (0 != CLOSE (daemon->epoll_fd)) )
+ (0 != close (daemon->epoll_fd)) )
MHD_PANIC ("close failed\n");
#endif
@@ -3595,9 +3669,9 @@
if (-1 != daemon->wpipe[1])
{
- if (0 != CLOSE (daemon->wpipe[0]))
+ if (0 != close (daemon->wpipe[0]))
MHD_PANIC ("close failed\n");
- if (0 != CLOSE (daemon->wpipe[1]))
+ if (0 != close (daemon->wpipe[1]))
MHD_PANIC ("close failed\n");
}
free (daemon);
@@ -3687,15 +3761,12 @@
/**
* Initialize do setup work.
*/
-void ATTRIBUTE_CONSTRUCTOR
+void ATTRIBUTE_CONSTRUCTOR
MHD_init ()
{
mhd_panic = &mhd_panic_std;
mhd_panic_cls = NULL;
-#ifdef WINDOWS
- plibc_init ("GNU", "libmicrohttpd");
-#endif
#if HTTPS_SUPPORT
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
gnutls_global_init ();
@@ -3703,15 +3774,12 @@
}
-void ATTRIBUTE_DESTRUCTOR
+void ATTRIBUTE_DESTRUCTOR
MHD_fini ()
{
#if HTTPS_SUPPORT
gnutls_global_deinit ();
#endif
-#ifdef WINDOWS
- plibc_shutdown ();
-#endif
}
/* end of daemon.c */
Modified: libmicrohttpd/src/microhttpd/memorypool.c
===================================================================
--- libmicrohttpd/src/microhttpd/memorypool.c 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/microhttpd/memorypool.c 2013-08-07 06:41:45 UTC (rev
28427)
@@ -95,7 +95,7 @@
if (max <= 32 * 1024)
pool->memory = MAP_FAILED;
else
- pool->memory = MMAP (NULL, max, PROT_READ | PROT_WRITE,
+ pool->memory = mmap (NULL, max, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#else
pool->memory = MAP_FAILED;
@@ -134,7 +134,11 @@
if (pool->is_mmap == MHD_NO)
free (pool->memory);
else
- MUNMAP (pool->memory, pool->size);
+#ifndef WINDOWS
+ munmap (pool->memory, pool->size);
+#else
+ VirtualFree (pool->memory, 0, MEM_RELEASE);
+#endif
free (pool);
}
@@ -151,7 +155,7 @@
* bytes
*/
void *
-MHD_pool_allocate (struct MemoryPool *pool,
+MHD_pool_allocate (struct MemoryPool *pool,
size_t size, int from_end)
{
void *ret;
@@ -192,8 +196,8 @@
*/
void *
MHD_pool_reallocate (struct MemoryPool *pool,
- void *old,
- size_t old_size,
+ void *old,
+ size_t old_size,
size_t new_size)
{
void *ret;
@@ -242,8 +246,8 @@
* @return addr new address of "keep" (if it had to change)
*/
void *
-MHD_pool_reset (struct MemoryPool *pool,
- void *keep,
+MHD_pool_reset (struct MemoryPool *pool,
+ void *keep,
size_t size)
{
size = ROUND_TO_ALIGN (size);
Modified: libmicrohttpd/src/microspdy/Makefile.am
===================================================================
--- libmicrohttpd/src/microspdy/Makefile.am 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/microspdy/Makefile.am 2013-08-07 06:41:45 UTC (rev
28427)
@@ -1,9 +1,4 @@
-if USE_PRIVATE_PLIBC_H
- PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc
-endif
-
AM_CPPFLAGS = \
- $(PLIBC_INCLUDE) \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/microspdy
Modified: libmicrohttpd/src/spdy2http/Makefile.am
===================================================================
--- libmicrohttpd/src/spdy2http/Makefile.am 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/spdy2http/Makefile.am 2013-08-07 06:41:45 UTC (rev
28427)
@@ -6,12 +6,7 @@
AM_CFLAGS += -fprofile-arcs -ftest-coverage
endif
-if USE_PRIVATE_PLIBC_H
- PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc
-endif
-
AM_CPPFLAGS = \
- $(PLIBC_INCLUDE) \
-I$(top_srcdir) \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/applicationlayer \
Modified: libmicrohttpd/src/testspdy/Makefile.am
===================================================================
--- libmicrohttpd/src/testspdy/Makefile.am 2013-08-07 06:22:16 UTC (rev
28426)
+++ libmicrohttpd/src/testspdy/Makefile.am 2013-08-07 06:41:45 UTC (rev
28427)
@@ -6,12 +6,7 @@
AM_CFLAGS += -fprofile-arcs -ftest-coverage
endif
-if USE_PRIVATE_PLIBC_H
- PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc
-endif
-
AM_CPPFLAGS = \
- $(PLIBC_INCLUDE) \
-I$(top_srcdir) \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/applicationlayer \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28427 - in libmicrohttpd/src: examples include microhttpd microspdy spdy2http testspdy,
gnunet <=