changed configure.ac to detect dirfd() and related stuffs.
changed lib/cmn/syscall.h to use DIRFD related macros produced by configure
This commit is contained in:
		| @ -46,6 +46,7 @@ | ||||
|  | ||||
| #elif defined(__DOS__) | ||||
| #	include <errno.h> | ||||
|  | ||||
| #else | ||||
| #	include <unistd.h> | ||||
| #	include <fcntl.h> | ||||
| @ -53,7 +54,11 @@ | ||||
| #	if defined(HAVE_SYS_TIME_H) | ||||
| #		include <sys/time.h> | ||||
| #	endif | ||||
| #	if defined(HAVE_SYS_EVENT_H) && defined(HAVE_KQUEUE) && defined(HAVE_KEVENT) | ||||
|  | ||||
| #	if defined(QSE_MUX_USE_SELECT) | ||||
| 		/* you can set QSE_MUX_USE_SELECT to force using select() */ | ||||
| #		define USE_SELECT | ||||
| #	elif defined(HAVE_SYS_EVENT_H) && defined(HAVE_KQUEUE) && defined(HAVE_KEVENT) | ||||
| #		include <sys/event.h> | ||||
| #		define USE_KQUEUE | ||||
| #	elif defined(HAVE_SYS_EPOLL_H) | ||||
| @ -61,9 +66,11 @@ | ||||
| #		if defined(HAVE_EPOLL_CREATE) | ||||
| #			define USE_EPOLL | ||||
| #		endif | ||||
| /* | ||||
| #	elif defined(HAVE_POLL_H) | ||||
| 		/* TODO */ | ||||
| 		TODO: IMPLEMENT THIS | ||||
| #		define USE_POLL | ||||
| */ | ||||
| #	else | ||||
| #		define USE_SELECT | ||||
| #	endif | ||||
|  | ||||
| @ -604,7 +604,7 @@ qse_size_t qse_nwadtowcs ( | ||||
| 					if (flags & QSE_NWADTOMBS_ADDR) | ||||
| 					{ | ||||
| 						if (xlen + 1 >= len) goto done; | ||||
| 						buf[xlen++] = QSE_WT(']');	 | ||||
| 						buf[xlen++] = QSE_WT(']'); | ||||
|  | ||||
| 						if (xlen + 1 >= len) goto done; | ||||
| 						buf[xlen++] = QSE_WT(':'); | ||||
|  | ||||
| @ -376,7 +376,13 @@ static int close_unneeded_fds_using_proc (int* excepts, qse_size_t count) | ||||
| 		qse_mchar_t buf[64]; | ||||
| 		qse_mbsxfmt (buf, QSE_COUNTOF(buf), QSE_MT("/proc/%d/fd"), QSE_GETPID()); | ||||
| 		d = QSE_OPENDIR (buf); | ||||
| 	#if !defined(_SCO_DS) | ||||
| 		/* on SCO OpenServer, a range of file descriptors starting from 0 are | ||||
| 		 * listed under /dev/fd regardless of opening state. And some high  | ||||
| 		 * numbered descriptors are not listed all. not reliable */ | ||||
|  | ||||
| 		if (!d) d = QSE_OPENDIR (QSE_MT("/dev/fd")); /* Darwin, FreeBSD */ | ||||
| 	#endif | ||||
| 	} | ||||
|  | ||||
| 	if (d) | ||||
|  | ||||
| @ -51,6 +51,14 @@ | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #if !defined(SHUT_RD) | ||||
| #	define SHUT_RD 0 | ||||
| #endif | ||||
|  | ||||
| #if !defined(SHUT_WR) | ||||
| #	define SHUT_WR 1 | ||||
| #endif | ||||
|  | ||||
| #if !defined(SHUT_RDWR) | ||||
| #	define SHUT_RDWR 2 | ||||
| #endif | ||||
|  | ||||
| @ -372,7 +372,15 @@ | ||||
| #define QSE_OPENDIR(name) opendir(name) | ||||
| #define QSE_CLOSEDIR(dir) closedir(dir) | ||||
| #define QSE_REWINDDIR(dir) rewinddir(dir) | ||||
| #define QSE_DIRFD(dir) dirfd(dir) | ||||
| #if defined(HAVE_DIRFD) | ||||
| #	define QSE_DIRFD(dir) dirfd(dir) | ||||
| #elif defined(HAVE_DIR_DD_FD) | ||||
| #	define QSE_DIRFD(dir) ((dir)->dd_fd) | ||||
| #elif defined(HAVE_DIR_D_FD) | ||||
| #	define QSE_DIRFD(dir) ((dir)->d_fd) | ||||
| #else | ||||
| #	error OUCH!!! NO DIRFD AVAILABLE | ||||
| #endif | ||||
| #define QSE_DIR DIR | ||||
|  | ||||
| #if defined(HAVE_READDIR64) | ||||
|  | ||||
| @ -184,7 +184,7 @@ struct dns_ans_t | ||||
| 	 * this condition is required for reusing the dns_req_t chunk | ||||
| 	 * when caching an answer without allocating another chunk. */ | ||||
| 	qse_nwad_t nwad; | ||||
| 	qse_int64_t age; | ||||
| 	qse_long_t age; | ||||
| 	qse_uint32_t ttl; | ||||
| 	dns_ans_t* next; | ||||
| }; | ||||
| @ -539,7 +539,7 @@ static int dns_recv (qse_httpd_t* httpd, qse_httpd_dns_t* dns, qse_httpd_hnd_t h | ||||
| 	httpd_xtn_t* httpd_xtn; | ||||
|  | ||||
| 	qse_skad_t fromaddr; | ||||
| 	socklen_t fromlen; | ||||
| 	qse_sck_len_t fromlen; | ||||
|  | ||||
| 	qse_uint8_t buf[DNS_MAX_MSG_LEN]; | ||||
| 	qse_ssize_t len; | ||||
|  | ||||
| @ -95,12 +95,13 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs) | ||||
| 	qse_nwad_t nwad; | ||||
| 	urs_ctx_t* dc; | ||||
| 	httpd_xtn_t* httpd_xtn; | ||||
| 	int type, proto = IPPROTO_UDP; //IPPROTO_SCTP; | ||||
| 	int type, proto = IPPROTO_UDP; /*IPPROTO_SCTP*/ | ||||
|  | ||||
| 	httpd_xtn = qse_httpd_getxtn (httpd); | ||||
|  | ||||
| 	urs->handle[0] = QSE_INVALID_SCKHND; | ||||
| 	urs->handle[1] = QSE_INVALID_SCKHND; | ||||
| 	urs->handle[2] = QSE_INVALID_SCKHND; | ||||
|  | ||||
| 	dc = (urs_ctx_t*) qse_httpd_callocmem (httpd, QSE_SIZEOF(urs_ctx_t)); | ||||
| 	if (dc == NULL) goto oops; | ||||
| @ -132,6 +133,7 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs) | ||||
| #if defined(AF_INET6) | ||||
| 	urs->handle[1] = open_udp_socket (httpd, AF_INET6, type, proto); | ||||
| #endif | ||||
| 	/*urs->handle[2] = open_unix_socket (httpd, AF_UNIX, SOCK_DGRAM);*/ | ||||
|  | ||||
| 	if (!qse_isvalidsckhnd(urs->handle[0]) && !qse_isvalidsckhnd(urs->handle[1])) | ||||
| 	{ | ||||
| @ -160,12 +162,14 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs) | ||||
| /* TODO: error ahndleing */ | ||||
| 		if (qse_isvalidsckhnd(urs->handle[0])) listen (urs->handle[0], 99); | ||||
| 		if (qse_isvalidsckhnd(urs->handle[1])) listen (urs->handle[1], 99); | ||||
| 		/* handle[2] is a unix socket. no special handling for SCTP */ | ||||
| 	} | ||||
| #endif | ||||
|  | ||||
| 	urs->handle_count = 2; | ||||
| 	urs->handle_count = 3; | ||||
| 	if (qse_isvalidsckhnd(urs->handle[0])) urs->handle_mask |= (1 << 0); | ||||
| 	if (qse_isvalidsckhnd(urs->handle[1])) urs->handle_mask |= (1 << 1); | ||||
| 	if (qse_isvalidsckhnd(urs->handle[2])) urs->handle_mask |= (1 << 2); | ||||
|  | ||||
| 	urs->ctx = dc; | ||||
| 	return 0; | ||||
| @ -173,6 +177,7 @@ static int urs_open (qse_httpd_t* httpd, qse_httpd_urs_t* urs) | ||||
| oops: | ||||
| 	if (qse_isvalidsckhnd(urs->handle[0])) qse_closesckhnd (urs->handle[0]); | ||||
| 	if (qse_isvalidsckhnd(urs->handle[1])) qse_closesckhnd (urs->handle[1]); | ||||
| 	if (qse_isvalidsckhnd(urs->handle[2])) qse_closesckhnd (urs->handle[2]); | ||||
| 	if (dc) qse_httpd_freemem (httpd, dc); | ||||
| 	return -1; | ||||
|  | ||||
| @ -210,6 +215,7 @@ static void urs_close (qse_httpd_t* httpd, qse_httpd_urs_t* urs) | ||||
|  | ||||
| 	if (qse_isvalidsckhnd(urs->handle[0])) qse_closesckhnd (urs->handle[0]); | ||||
| 	if (qse_isvalidsckhnd(urs->handle[1])) qse_closesckhnd (urs->handle[1]); | ||||
| 	if (qse_isvalidsckhnd(urs->handle[2])) qse_closesckhnd (urs->handle[2]); | ||||
| 	qse_httpd_freemem (httpd, urs->ctx); | ||||
| } | ||||
|  | ||||
| @ -220,7 +226,7 @@ static int urs_recv (qse_httpd_t* httpd, qse_httpd_urs_t* urs, qse_httpd_hnd_t h | ||||
| 	httpd_xtn_t* httpd_xtn; | ||||
|  | ||||
| 	qse_skad_t fromaddr; | ||||
| 	socklen_t fromlen; | ||||
| 	qse_sck_len_t fromlen; | ||||
|  | ||||
| 	qse_uint16_t xid; | ||||
| 	qse_ssize_t len, url_len; | ||||
| @ -358,7 +364,6 @@ static int urs_send (qse_httpd_t* httpd, qse_httpd_urs_t* urs, const qse_mchar_t | ||||
| 	urs_req_t* req = QSE_NULL; | ||||
| 	qse_size_t url_len; | ||||
| 	qse_tmr_event_t tmout_event; | ||||
| 	 | ||||
|  | ||||
| printf ("... URS_SEND.....................\n"); | ||||
| 	httpd_xtn = qse_httpd_getxtn (httpd); | ||||
|  | ||||
| @ -2154,8 +2154,8 @@ if (qse_htre_getcontentlen(req) > 0) | ||||
| 		else  | ||||
| 		{ | ||||
| 			if (mth == QSE_HTTP_POST && | ||||
| 				!(req->flags & QSE_HTRE_ATTR_LENGTH) && | ||||
| 				!(req->flags & QSE_HTRE_ATTR_CHUNKED)) | ||||
| 			    !(req->flags & QSE_HTRE_ATTR_LENGTH) && | ||||
| 			    !(req->flags & QSE_HTRE_ATTR_CHUNKED)) | ||||
| 			{ | ||||
| 				/* POST without Content-Length nor not chunked */ | ||||
| 				req->flags &= ~QSE_HTRE_ATTR_KEEPALIVE; | ||||
| @ -2181,8 +2181,8 @@ if (qse_htre_getcontentlen(req) > 0) | ||||
| 			{ | ||||
| 				task = QSE_NULL; | ||||
|  | ||||
| 				if ((rsrc.flags & QSE_HTTPD_RSRC_100_CONTINUE) &&  | ||||
| 					(task = qse_httpd_entaskcontinue (httpd, client, task, req)) == QSE_NULL)  | ||||
| 				if ((rsrc.flags & QSE_HTTPD_RSRC_100_CONTINUE) && | ||||
| 				    (task = qse_httpd_entaskcontinue (httpd, client, task, req)) == QSE_NULL)  | ||||
| 				{ | ||||
| 					/* inject '100 continue' first if it is needed */ | ||||
| 					goto oops; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user