move SET_SOCKOPT_NOSIGPIPE from sockopt.c to sockopt.h

pull/10/head
yuqing 2016-11-10 14:00:12 +08:00
parent ca5eefc8d2
commit 41db7d0bc2
3 changed files with 16 additions and 13 deletions

View File

@ -1,4 +1,7 @@
Version 1.31 2016-11-10
* move SET_SOCKOPT_NOSIGPIPE from sockopt.c to sockopt.h
Version 1.30 2016-10-31 Version 1.30 2016-10-31
* modify php-fastcommon/test.php * modify php-fastcommon/test.php
* php7_ext_wrapper.h: fix memory leak in php 7 * php7_ext_wrapper.h: fix memory leak in php 7

View File

@ -13,9 +13,6 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
@ -871,16 +868,6 @@ int socketBind(int sock, const char *bind_ipaddr, const int port)
return 0; return 0;
} }
#ifdef SO_NOSIGPIPE
#define SET_SOCKOPT_NOSIGPIPE(sock) \
do { \
int set = 1; \
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(int)); \
} while (0)
#else
#define SET_SOCKOPT_NOSIGPIPE(sock)
#endif
int socketServer(const char *bind_ipaddr, const int port, int *err_no) int socketServer(const char *bind_ipaddr, const int port, int *err_no)
{ {
int sock; int sock;

View File

@ -13,6 +13,9 @@
#include <net/if.h> #include <net/if.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "common_define.h" #include "common_define.h"
#define FAST_WRITE_BUFF_SIZE 256 * 1024 #define FAST_WRITE_BUFF_SIZE 256 * 1024
@ -29,6 +32,16 @@ typedef struct ip_addr_s {
int socket_domain; int socket_domain;
} ip_addr_t; } ip_addr_t;
#ifdef SO_NOSIGPIPE
#define SET_SOCKOPT_NOSIGPIPE(sock) \
do { \
int set = 1; \
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(int)); \
} while (0)
#else
#define SET_SOCKOPT_NOSIGPIPE(sock)
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif