[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32392 - in libmicrohttpd/src: . microhttpd platform testcu
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32392 - in libmicrohttpd/src: . microhttpd platform testcurl testcurl/https |
Date: |
Tue, 18 Feb 2014 19:38:05 +0100 |
Author: Karlson2k
Date: 2014-02-18 19:38:04 +0100 (Tue, 18 Feb 2014)
New Revision: 32392
Added:
libmicrohttpd/src/platform/
libmicrohttpd/src/platform/platform_interface.h
Modified:
libmicrohttpd/src/microhttpd/Makefile.am
libmicrohttpd/src/microhttpd/daemon.c
libmicrohttpd/src/testcurl/Makefile.am
libmicrohttpd/src/testcurl/https/Makefile.am
libmicrohttpd/src/testcurl/test_get.c
Log:
Replace CLOSE() with MHD_socket_close_() for sockets
Modified: libmicrohttpd/src/microhttpd/Makefile.am
===================================================================
--- libmicrohttpd/src/microhttpd/Makefile.am 2014-02-18 18:37:48 UTC (rev
32391)
+++ libmicrohttpd/src/microhttpd/Makefile.am 2014-02-18 18:38:04 UTC (rev
32392)
@@ -5,7 +5,8 @@
AM_CPPFLAGS = \
$(PLIBC_INCLUDE) \
-I$(top_srcdir)/src/include \
- -I$(top_srcdir)/src/microhttpd
+ -I$(top_srcdir)/src/microhttpd \
+ -I$(top_srcdir)/src/platform
AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) \
@LIBGCRYPT_CFLAGS@
@@ -20,7 +21,8 @@
daemon.c \
internal.c internal.h \
memorypool.c memorypool.h \
- response.c response.h
+ response.c response.h \
+ ../platform/platform_interface.h
libmicrohttpd_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DBUILDING_MHD_LIB=1
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2014-02-18 18:37:48 UTC (rev
32391)
+++ libmicrohttpd/src/microhttpd/daemon.c 2014-02-18 18:38:04 UTC (rev
32392)
@@ -25,6 +25,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include "platform_interface.h"
#include "internal.h"
#include "response.h"
#include "connection.h"
@@ -1052,7 +1053,7 @@
addr, addrlen,
external_add);
/* all pools are at their connection limit, must refuse */
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
#if ENFILE
errno = ENFILE;
@@ -1070,7 +1071,7 @@
client_socket,
FD_SETSIZE);
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
#if EINVAL
errno = EINVAL;
@@ -1093,7 +1094,7 @@
MHD_DLOG (daemon,
"Server reached connection limit (closing inbound
connection)\n");
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
#if ENFILE
errno = ENFILE;
@@ -1111,7 +1112,7 @@
MHD_DLOG (daemon, "Connection rejected, closing connection\n");
#endif
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
#if EACCESS
@@ -1138,7 +1139,7 @@
"Error allocating memory: %s\n",
STRERROR (errno));
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
errno = eno;
@@ -1153,7 +1154,7 @@
"Error allocating memory: %s\n",
STRERROR (errno));
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
free (connection);
@@ -1172,7 +1173,7 @@
"Error allocating memory: %s\n",
STRERROR (errno));
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
MHD_pool_destroy (connection->pool);
@@ -1209,8 +1210,7 @@
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
- "Failed to make socket %d non-blocking: %s\n",
- connection->socket_fd,
+ "Failed to make socket non-blocking: %s\n",
STRERROR (errno));
#endif
}
@@ -1252,7 +1252,7 @@
"Failed to setup TLS credentials: unknown credential type
%d\n",
daemon->cred_type);
#endif
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
free (connection->addr);
@@ -1351,7 +1351,7 @@
daemon->max_connections--;
return MHD_YES;
cleanup:
- if (0 != CLOSE (client_socket))
+ if (0 != MHD_socket_close_ (client_socket))
MHD_PANIC ("close failed\n");
MHD_ip_limit_del (daemon, addr, addrlen);
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
@@ -1721,7 +1721,7 @@
#endif
if (MHD_INVALID_SOCKET != s)
{
- if (0 != CLOSE (s))
+ if (0 != MHD_socket_close_ (s))
MHD_PANIC ("close failed\n");
/* just in case */
}
@@ -1816,7 +1816,7 @@
#ifdef WINDOWS
SHUTDOWN (pos->socket_fd, SHUT_WR);
#endif
- if (0 != CLOSE (pos->socket_fd))
+ if (0 != MHD_socket_close_ (pos->socket_fd))
MHD_PANIC ("close failed\n");
}
if (NULL != pos->addr)
@@ -3530,7 +3530,7 @@
(unsigned int) port,
STRERROR (errno));
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != MHD_socket_close_ (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3545,7 +3545,7 @@
"Failed to make listen socket non-blocking: %s\n",
STRERROR (errno));
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != MHD_socket_close_ (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3559,7 +3559,7 @@
"Failed to listen for connections: %s\n",
STRERROR (errno));
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != MHD_socket_close_ (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3579,7 +3579,7 @@
socket_fd,
FD_SETSIZE);
#endif
- if (0 != CLOSE (socket_fd))
+ if (0 != MHD_socket_close_ (socket_fd))
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3592,7 +3592,7 @@
"MHD failed to initialize IP connection limit mutex\n");
#endif
if ( (MHD_INVALID_SOCKET != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != MHD_socket_close_ (socket_fd)) )
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3604,7 +3604,7 @@
#endif
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
if ( (MHD_INVALID_SOCKET != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != MHD_socket_close_ (socket_fd)) )
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3618,7 +3618,7 @@
"Failed to initialize TLS support\n");
#endif
if ( (MHD_INVALID_SOCKET != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != MHD_socket_close_ (socket_fd)) )
MHD_PANIC ("close failed\n");
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
@@ -3640,7 +3640,7 @@
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
if ( (MHD_INVALID_SOCKET != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != MHD_socket_close_ (socket_fd)) )
MHD_PANIC ("close failed\n");
goto free_and_fail;
}
@@ -3783,7 +3783,7 @@
if (0 == i)
{
if ( (MHD_INVALID_SOCKET != socket_fd) &&
- (0 != CLOSE (socket_fd)) )
+ (0 != MHD_socket_close_ (socket_fd)) )
MHD_PANIC ("close failed\n");
pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
@@ -4001,7 +4001,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 != MHD_socket_close_ (daemon->worker_pool[i].epoll_fd)) )
MHD_PANIC ("close failed\n");
#endif
if ( (MHD_USE_SUSPEND_RESUME == (daemon->options &
MHD_USE_SUSPEND_RESUME)) )
@@ -4032,7 +4032,7 @@
}
close_all_connections (daemon);
if ( (MHD_INVALID_SOCKET != fd) &&
- (0 != CLOSE (fd)) )
+ (0 != MHD_socket_close_ (fd)) )
MHD_PANIC ("close failed\n");
/* TLS clean up */
@@ -4047,7 +4047,7 @@
#if EPOLL_SUPPORT
if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) &&
(-1 != daemon->epoll_fd) &&
- (0 != CLOSE (daemon->epoll_fd)) )
+ (0 != MHD_socket_close_ (daemon->epoll_fd)) )
MHD_PANIC ("close failed\n");
#endif
Added: libmicrohttpd/src/platform/platform_interface.h
===================================================================
--- libmicrohttpd/src/platform/platform_interface.h
(rev 0)
+++ libmicrohttpd/src/platform/platform_interface.h 2014-02-18 18:38:04 UTC
(rev 32392)
@@ -0,0 +1,36 @@
+/*
+ This file is part of libmicrohttpd
+ (C) 2014 Karlson2k (Evgeny Grin)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library.
+ If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file platform/platfrom_interface.h
+ * @brief internal platform abstraction functions
+ * @author Karlson2k (Evgeny Grin)
+ */
+
+#ifndef MHD_PLATFORM_INTERFACE_H
+#define MHD_PLATFORM_INTERFACE_H
+
+/* MHD_socket_close_(fd) close any FDs (non-W32) / close only socket FDs (W32)
*/
+#if !defined(_WIN32) || defined(__CYGWIN__)
+#define MHD_socket_close_(fd) close((fd))
+#else
+#define MHD_socket_close_(fd) closesocket((fd))
+#endif
+
+#endif // MHD_PLATFORM_INTERFACE_H
Modified: libmicrohttpd/src/testcurl/Makefile.am
===================================================================
--- libmicrohttpd/src/testcurl/Makefile.am 2014-02-18 18:37:48 UTC (rev
32391)
+++ libmicrohttpd/src/testcurl/Makefile.am 2014-02-18 18:38:04 UTC (rev
32392)
@@ -17,6 +17,7 @@
-I$(top_srcdir) \
-I$(top_srcdir)/src/microhttpd \
-I$(top_srcdir)/src/include \
+-I$(top_srcdir)/src/platform \
$(LIBCURL_CPPFLAGS)
if !HAVE_W32
Modified: libmicrohttpd/src/testcurl/https/Makefile.am
===================================================================
--- libmicrohttpd/src/testcurl/https/Makefile.am 2014-02-18 18:37:48 UTC
(rev 32391)
+++ libmicrohttpd/src/testcurl/https/Makefile.am 2014-02-18 18:38:04 UTC
(rev 32392)
@@ -12,6 +12,7 @@
$(PLIBC_INCLUDE) \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/microhttpd \
+ -I$(top_srcdir)/src/platform \
$(LIBCURL_CPPFLAGS)
check_PROGRAMS = \
Modified: libmicrohttpd/src/testcurl/test_get.c
===================================================================
--- libmicrohttpd/src/testcurl/test_get.c 2014-02-18 18:37:48 UTC (rev
32391)
+++ libmicrohttpd/src/testcurl/test_get.c 2014-02-18 18:38:04 UTC (rev
32392)
@@ -27,6 +27,7 @@
#include "MHD_config.h"
#include "platform.h"
+#include "platform_interface.h"
#include <curl/curl.h>
#include <microhttpd.h>
#include <stdlib.h>
@@ -472,7 +473,7 @@
if (CONNECT (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0)
{
fprintf(stderr, "connect: %m\n");
- CLOSE (fd);
+ MHD_socket_close_ (fd);
return 512;
}
@@ -483,7 +484,7 @@
/* printf("Stopping daemon\n"); */
MHD_stop_daemon (d);
- CLOSE (fd);
+ MHD_socket_close_ (fd);
/* printf("good\n"); */
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32392 - in libmicrohttpd/src: . microhttpd platform testcurl testcurl/https,
gnunet <=