added a debug message
This commit is contained in:
		| @ -154,6 +154,7 @@ static int listener_on_read (mio_dev_sck_t* sck, const void* buf, mio_iolen_t le | |||||||
|  |  | ||||||
| 	if ((x = mio_htrd_feed(cli->htrd, buf, len, &rem)) <= -1)  | 	if ((x = mio_htrd_feed(cli->htrd, buf, len, &rem)) <= -1)  | ||||||
| 	{ | 	{ | ||||||
|  | 		MIO_DEBUG3 (mio, "HTTS(%p) - feed error onto client htrd %p(%d)\n", cli->htts, sck, (int)sck->hnd); | ||||||
| 		goto oops; | 		goto oops; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @ -173,7 +174,7 @@ static int listener_on_read (mio_dev_sck_t* sck, const void* buf, mio_iolen_t le | |||||||
|  |  | ||||||
| oops: | oops: | ||||||
| 	mio_dev_sck_halt (sck); | 	mio_dev_sck_halt (sck); | ||||||
| 	return 0; | 	return 0; /* still return success here. instead call halt() */ | ||||||
| } | } | ||||||
|  |  | ||||||
| static int listener_on_write (mio_dev_sck_t* sck, mio_iolen_t wrlen, void* wrctx, const mio_skad_t* dstaddr) | static int listener_on_write (mio_dev_sck_t* sck, mio_iolen_t wrlen, void* wrctx, const mio_skad_t* dstaddr) | ||||||
| @ -261,6 +262,7 @@ static void listener_on_disconnect (mio_dev_sck_t* sck) | |||||||
| 		MIO_ASSERT (mio, cli->sbuf == MIO_NULL); | 		MIO_ASSERT (mio, cli->sbuf == MIO_NULL); | ||||||
|  |  | ||||||
| 		MIO_DEBUG2 (mio, "HTTS(%p) - listener socket disconnect %p\n", cli->htts, sck); | 		MIO_DEBUG2 (mio, "HTTS(%p) - listener socket disconnect %p\n", cli->htts, sck); | ||||||
|  | printf ("listener socket disconnect..................sck %p %d\n", sck, sck->hnd); | ||||||
| 		cli->htts->lsck = MIO_NULL; /* let the htts service forget about this listening socket */ | 		cli->htts->lsck = MIO_NULL; /* let the htts service forget about this listening socket */ | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| @ -318,7 +320,7 @@ mio_svc_htts_t* mio_svc_htts_start (mio_t* mio, mio_dev_sck_bind_t* sck_bind, mi | |||||||
| 	if (!htts->lsck) goto oops; | 	if (!htts->lsck) goto oops; | ||||||
|  |  | ||||||
| 	/* the name 'cli' for the listening socket is awkard. | 	/* the name 'cli' for the listening socket is awkard. | ||||||
| 	 * the listing socket will use the htts and sck fields for tracking only. | 	 * the listening socket will use the htts and sck fields for tracking only. | ||||||
| 	 * each accepted client socket gets the extension size for this size as well. | 	 * each accepted client socket gets the extension size for this size as well. | ||||||
| 	 * most of other fields are used for client management */ | 	 * most of other fields are used for client management */ | ||||||
| 	cli = (mio_svc_htts_cli_t*)mio_dev_sck_getxtn(htts->lsck); | 	cli = (mio_svc_htts_cli_t*)mio_dev_sck_getxtn(htts->lsck); | ||||||
|  | |||||||
| @ -324,7 +324,6 @@ static void fire_cwq_handlers (mio_t* mio) | |||||||
| 		cwq = MIO_CWQ_HEAD(&mio->cwq); | 		cwq = MIO_CWQ_HEAD(&mio->cwq); | ||||||
| 		if (cwq->dev->dev_evcb->on_write(cwq->dev, cwq->olen, cwq->ctx, &cwq->dstaddr) <= -1)  | 		if (cwq->dev->dev_evcb->on_write(cwq->dev, cwq->olen, cwq->ctx, &cwq->dstaddr) <= -1)  | ||||||
| 		{ | 		{ | ||||||
| 			MIO_DEBUG1 (mio, "MIO - Error returned by on_write() of device %p in cwq\n", cwq->dev); |  | ||||||
| 			dev_to_halt = cwq->dev; | 			dev_to_halt = cwq->dev; | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| @ -347,7 +346,11 @@ static void fire_cwq_handlers (mio_t* mio) | |||||||
| 			mio_freemem (mio, cwq); | 			mio_freemem (mio, cwq); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (dev_to_halt) mio_dev_halt (dev_to_halt); | 		if (dev_to_halt)  | ||||||
|  | 		{ | ||||||
|  | 			MIO_DEBUG1 (mio, "DEV(%p) - halting a device for on_write error upon write completion[1]\n", dev_to_halt); | ||||||
|  | 			mio_dev_halt (dev_to_halt); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -368,7 +371,6 @@ static void fire_cwq_handlers_for_dev (mio_t* mio, mio_dev_t* dev, int for_kill) | |||||||
|  |  | ||||||
| 			if (cwq->dev->dev_evcb->on_write(cwq->dev, cwq->olen, cwq->ctx, &cwq->dstaddr) <= -1)  | 			if (cwq->dev->dev_evcb->on_write(cwq->dev, cwq->olen, cwq->ctx, &cwq->dstaddr) <= -1)  | ||||||
| 			{ | 			{ | ||||||
| 				MIO_DEBUG1 (mio, "MIO - Error returned by on_write() of device %p in cwq\n", cwq->dev); |  | ||||||
| 				dev_to_halt = cwq->dev; | 				dev_to_halt = cwq->dev; | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| @ -392,7 +394,11 @@ static void fire_cwq_handlers_for_dev (mio_t* mio, mio_dev_t* dev, int for_kill) | |||||||
| 				mio_freemem (mio, cwq); | 				mio_freemem (mio, cwq); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (!for_kill && dev_to_halt) mio_dev_halt (dev_to_halt); | 			if (!for_kill && dev_to_halt) | ||||||
|  | 			{ | ||||||
|  | 				MIO_DEBUG1 (mio, "DEV(%p) - halting a device for on_write error upon write completion[2]\n", dev_to_halt); | ||||||
|  | 			       	mio_dev_halt (dev_to_halt); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 		cwq = next; | 		cwq = next; | ||||||
| 	} | 	} | ||||||
| @ -420,7 +426,8 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 		 *   >= 1 - everything is ok. */ | 		 *   >= 1 - everything is ok. */ | ||||||
| 		x = dev->dev_evcb->ready(dev, xevents); | 		x = dev->dev_evcb->ready(dev, xevents); | ||||||
| 		if (x <= -1) | 		if (x <= -1) | ||||||
| 		{ | 		{  | ||||||
|  | 			MIO_DEBUG1 (mio, "DEV(%p) - halting a device for ready callback error\n", dev); | ||||||
| 			mio_dev_halt (dev); | 			mio_dev_halt (dev); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| @ -461,6 +468,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 			} | 			} | ||||||
| 			if (x <= -1) | 			if (x <= -1) | ||||||
| 			{ | 			{ | ||||||
|  | 				MIO_DEBUG1 (mio, "DEV(%p) - halting a device for write failure\n", dev); | ||||||
| 				mio_dev_halt (dev); | 				mio_dev_halt (dev); | ||||||
| 				dev = MIO_NULL; | 				dev = MIO_NULL; | ||||||
| 				break; | 				break; | ||||||
| @ -504,7 +512,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
|  |  | ||||||
| 					if (y <= -1) | 					if (y <= -1) | ||||||
| 					{ | 					{ | ||||||
| 						MIO_DEBUG1 (mio, "MIO - Error returned by on_write() of device %p\n", dev); | 						MIO_DEBUG1 (mio, "DEV(%p) - halting a device for on_write error\n", dev); | ||||||
| 						mio_dev_halt (dev); | 						mio_dev_halt (dev); | ||||||
| 						dev = MIO_NULL; | 						dev = MIO_NULL; | ||||||
| 						break; | 						break; | ||||||
| @ -532,6 +540,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 			/* no pending request to write */ | 			/* no pending request to write */ | ||||||
| 			if ((dev->dev_cap & MIO_DEV_CAP_IN_CLOSED) && (dev->dev_cap & MIO_DEV_CAP_OUT_CLOSED)) | 			if ((dev->dev_cap & MIO_DEV_CAP_IN_CLOSED) && (dev->dev_cap & MIO_DEV_CAP_OUT_CLOSED)) | ||||||
| 			{ | 			{ | ||||||
|  | 				MIO_DEBUG1 (mio, "DEV(%p) - halting a device for closed input and output in output handler\n", dev); | ||||||
| 				mio_dev_halt (dev); | 				mio_dev_halt (dev); | ||||||
| 				dev = MIO_NULL; | 				dev = MIO_NULL; | ||||||
| 			} | 			} | ||||||
| @ -557,6 +566,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 			x = dev->dev_mth->read(dev, mio->bigbuf, &len, &srcaddr); | 			x = dev->dev_mth->read(dev, mio->bigbuf, &len, &srcaddr); | ||||||
| 			if (x <= -1) | 			if (x <= -1) | ||||||
| 			{ | 			{ | ||||||
|  | 				MIO_DEBUG1 (mio, "DEV(%p) - halting a device for read failure\n", dev); | ||||||
| 				mio_dev_halt (dev); | 				mio_dev_halt (dev); | ||||||
| 				dev = MIO_NULL; | 				dev = MIO_NULL; | ||||||
| 				break; | 				break; | ||||||
| @ -620,6 +630,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 					{ | 					{ | ||||||
| 						/* 1. input ended and its reporting failed or  | 						/* 1. input ended and its reporting failed or  | ||||||
| 						 * 2. input ended and no writing is possible */ | 						 * 2. input ended and no writing is possible */ | ||||||
|  | 						MIO_DEBUG1 (mio, "DEV(%p) - halting a stream device for on_read failure while output is closed\n", dev); | ||||||
| 						mio_dev_halt (dev); | 						mio_dev_halt (dev); | ||||||
| 						dev = MIO_NULL; | 						dev = MIO_NULL; | ||||||
| 					} | 					} | ||||||
| @ -637,6 +648,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 					y = dev->dev_evcb->on_read(dev, mio->bigbuf, len, &srcaddr); | 					y = dev->dev_evcb->on_read(dev, mio->bigbuf, len, &srcaddr); | ||||||
| 					if (y <= -1) | 					if (y <= -1) | ||||||
| 					{ | 					{ | ||||||
|  | 						MIO_DEBUG1 (mio, "DEV(%p) - halting a non-stream device for on_read failure while output is closed\n", dev); | ||||||
| 						mio_dev_halt (dev); | 						mio_dev_halt (dev); | ||||||
| 						dev = MIO_NULL; | 						dev = MIO_NULL; | ||||||
| 						break; | 						break; | ||||||
| @ -689,6 +701,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| 		if ((dev->dev_cap & MIO_DEV_CAP_IN_CLOSED) && | 		if ((dev->dev_cap & MIO_DEV_CAP_IN_CLOSED) && | ||||||
| 		    (dev->dev_cap & MIO_DEV_CAP_OUT_CLOSED)) | 		    (dev->dev_cap & MIO_DEV_CAP_OUT_CLOSED)) | ||||||
| 		{ | 		{ | ||||||
|  | 			MIO_DEBUG1 (mio, "DEV(%p) - halting a device for closed input and output\n", dev); | ||||||
| 			mio_dev_halt (dev); | 			mio_dev_halt (dev); | ||||||
| 			dev = MIO_NULL; | 			dev = MIO_NULL; | ||||||
| 		} | 		} | ||||||
| @ -697,6 +710,7 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int | |||||||
| skip_evcb: | skip_evcb: | ||||||
| 	if (dev && (dev->dev_cap & MIO_DEV_CAP_RENEW_REQUIRED) && mio_dev_watch(dev, MIO_DEV_WATCH_RENEW, MIO_DEV_EVENT_IN) <= -1) | 	if (dev && (dev->dev_cap & MIO_DEV_CAP_RENEW_REQUIRED) && mio_dev_watch(dev, MIO_DEV_WATCH_RENEW, MIO_DEV_EVENT_IN) <= -1) | ||||||
| 	{ | 	{ | ||||||
|  | 		MIO_DEBUG1 (mio, "DEV(%p) - halting a device for wathcer renewal failure\n", dev); | ||||||
| 		mio_dev_halt (dev); | 		mio_dev_halt (dev); | ||||||
| 		dev = MIO_NULL; | 		dev = MIO_NULL; | ||||||
| 	} | 	} | ||||||
| @ -1162,7 +1176,11 @@ static void on_read_timeout (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* j | |||||||
|  |  | ||||||
| 	MIO_ASSERT (mio, dev->rtmridx == MIO_TMRIDX_INVALID); | 	MIO_ASSERT (mio, dev->rtmridx == MIO_TMRIDX_INVALID); | ||||||
|  |  | ||||||
| 	if (x <= -1) mio_dev_halt (dev); | 	if (x <= -1)  | ||||||
|  | 	{ | ||||||
|  | 		MIO_DEBUG1 (mio, "DEV(%p) - halting a device for on_read error upon timeout\n", dev); | ||||||
|  | 		mio_dev_halt (dev); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| static int __dev_read (mio_dev_t* dev, int enabled, const mio_ntime_t* tmout, void* rdctx) | static int __dev_read (mio_dev_t* dev, int enabled, const mio_ntime_t* tmout, void* rdctx) | ||||||
| @ -1249,7 +1267,11 @@ static void on_write_timeout (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* | |||||||
| 	MIO_WQ_UNLINK(q); | 	MIO_WQ_UNLINK(q); | ||||||
| 	mio_freemem (mio, q); | 	mio_freemem (mio, q); | ||||||
|  |  | ||||||
| 	if (x <= -1) mio_dev_halt (dev); | 	if (x <= -1)  | ||||||
|  | 	{ | ||||||
|  | 		MIO_DEBUG1 (mio, "DEV(%p) - halting a device for on_write error upon timeout\n", dev); | ||||||
|  | 		mio_dev_halt (dev); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| static MIO_INLINE int __enqueue_completed_write (mio_dev_t* dev, mio_iolen_t len, void* wrctx, const mio_devaddr_t* dstaddr) | static MIO_INLINE int __enqueue_completed_write (mio_dev_t* dev, mio_iolen_t len, void* wrctx, const mio_devaddr_t* dstaddr) | ||||||
|  | |||||||
| @ -268,6 +268,7 @@ static void connect_timedout (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* | |||||||
| 		 * doesn't need to be deleted when it gets connected for this check  | 		 * doesn't need to be deleted when it gets connected for this check  | ||||||
| 		 * here. this libarary, however, deletes the job when it gets  | 		 * here. this libarary, however, deletes the job when it gets  | ||||||
| 		 * connected. */ | 		 * connected. */ | ||||||
|  | 		MIO_DEBUG1 (mio, "SCK(%p) - connect timed out. halting\n", rdev); | ||||||
| 		mio_dev_sck_halt (rdev); | 		mio_dev_sck_halt (rdev); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @ -280,6 +281,7 @@ static void ssl_accept_timedout (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_ | |||||||
|  |  | ||||||
| 	if (rdev->state & MIO_DEV_SCK_ACCEPTING_SSL) | 	if (rdev->state & MIO_DEV_SCK_ACCEPTING_SSL) | ||||||
| 	{ | 	{ | ||||||
|  | 		MIO_DEBUG1 (mio, "SCK(%p) - ssl-accept timed out. halting\n", rdev); | ||||||
| 		mio_dev_sck_halt(rdev); | 		mio_dev_sck_halt(rdev); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @ -292,6 +294,7 @@ static void ssl_connect_timedout (mio_t* mio, const mio_ntime_t* now, mio_tmrjob | |||||||
|  |  | ||||||
| 	if (rdev->state & MIO_DEV_SCK_CONNECTING_SSL) | 	if (rdev->state & MIO_DEV_SCK_CONNECTING_SSL) | ||||||
| 	{ | 	{ | ||||||
|  | 		MIO_DEBUG1 (mio, "SCK(%p) - ssl-connect timed out. halting\n", rdev); | ||||||
| 		mio_dev_sck_halt(rdev); | 		mio_dev_sck_halt(rdev); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @ -420,8 +423,11 @@ static int dev_sck_make_client (mio_dev_t* dev, void* ctx) | |||||||
| 	rdev->tmrjob_index = MIO_TMRIDX_INVALID; | 	rdev->tmrjob_index = MIO_TMRIDX_INVALID; | ||||||
| 	rdev->side_chan = MIO_SYSHND_INVALID; | 	rdev->side_chan = MIO_SYSHND_INVALID; | ||||||
|  |  | ||||||
| 	if (mio_makesyshndasync(mio, rdev->hnd) <= -1 || | /*if (mio_makesyshndasync(mio, rdev->hnd) <= -1 || | ||||||
| 	    mio_makesyshndcloexec(mio, rdev->hnd) <= -1) return -1; |     mio_makesyshndcloexec(mio, rdev->hnd) <= -1) { printf ("cannot make sysnhnd async or cloexec %d\n", rdev->hnd); return -1; } | ||||||
|  |  */ | ||||||
|  | 	mio_makesyshndasync(mio, rdev->hnd); | ||||||
|  | 	mio_makesyshndcloexec(mio, rdev->hnd); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -542,9 +548,13 @@ static int dev_sck_read_stateless (mio_dev_t* dev, void* buf, mio_iolen_t* len, | |||||||
| 	x = recvfrom(rdev->hnd, buf, *len, 0, (struct sockaddr*)&rdev->remoteaddr, &srcaddrlen); | 	x = recvfrom(rdev->hnd, buf, *len, 0, (struct sockaddr*)&rdev->remoteaddr, &srcaddrlen); | ||||||
| 	if (x <= -1) | 	if (x <= -1) | ||||||
| 	{ | 	{ | ||||||
| 		if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0;  /* no data available */ | 		int eno = errno; | ||||||
| 		if (errno == EINTR) return 0; | 		if (eno == EINPROGRESS || eno == EWOULDBLOCK || eno == EAGAIN) return 0;  /* no data available */ | ||||||
| 		mio_seterrwithsyserr (mio, 0, errno); | 		if (eno == EINTR) return 0; | ||||||
|  |  | ||||||
|  | 		mio_seterrwithsyserr (mio, 0, eno); | ||||||
|  |  | ||||||
|  | 		MIO_DEBUG2 (mio, "SCK(%p) - recvfrom failure - %hs", rdev, strerror(eno));  | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @ -1402,7 +1412,8 @@ static int harvest_outgoing_connection (mio_dev_sck_t* rdev) | |||||||
| 				if (MIO_IS_POS_NTIME(&rdev->tmout) && | 				if (MIO_IS_POS_NTIME(&rdev->tmout) && | ||||||
| 				    schedule_timer_job_at(rdev, &rdev->tmout, ssl_connect_timedout) <= -1) | 				    schedule_timer_job_at(rdev, &rdev->tmout, ssl_connect_timedout) <= -1) | ||||||
| 				{ | 				{ | ||||||
| 					mio_dev_halt ((mio_dev_t*)rdev); | 					MIO_DEBUG1 (mio, "SCK(%p) - ssl-connect timeout scheduling failed. halting\n", rdev); | ||||||
|  | 					mio_dev_sck_halt (rdev); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				return 0; | 				return 0; | ||||||
| @ -1458,13 +1469,11 @@ static int make_accepted_client_connection (mio_dev_sck_t* rdev, mio_syshnd_t cl | |||||||
| 	clidev = (mio_dev_sck_t*)mio_dev_make(mio, rdev->dev_size, &dev_mth_clisck, rdev->dev_evcb, &clisck);  | 	clidev = (mio_dev_sck_t*)mio_dev_make(mio, rdev->dev_size, &dev_mth_clisck, rdev->dev_evcb, &clisck);  | ||||||
| 	if (MIO_UNLIKELY(!clidev)) | 	if (MIO_UNLIKELY(!clidev)) | ||||||
| 	{ | 	{ | ||||||
|  | 		MIO_DEBUG3 (mio, "SCK(%p) - unable to make a new accepted device for %d - %js\n", rdev, (int)clisck, mio_geterrmsg(mio)); | ||||||
| 		close (clisck); | 		close (clisck); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| // TODO: |  | ||||||
| //if (clidev->type == MIO_DEV_SCK_QX) change it to the specified type.. |  | ||||||
| // TODO: |  | ||||||
| 	clidev->type = clisck_type; | 	clidev->type = clisck_type; | ||||||
| 	MIO_ASSERT (mio, clidev->hnd == clisck); | 	MIO_ASSERT (mio, clidev->hnd == clisck); | ||||||
|  |  | ||||||
| @ -1538,7 +1547,8 @@ static int make_accepted_client_connection (mio_dev_sck_t* rdev, mio_syshnd_t cl | |||||||
| 		    schedule_timer_job_after(clidev, &rdev->tmout, ssl_accept_timedout) <= -1) | 		    schedule_timer_job_after(clidev, &rdev->tmout, ssl_accept_timedout) <= -1) | ||||||
| 		{ | 		{ | ||||||
| 			/* timer job scheduling failed. halt the device */ | 			/* timer job scheduling failed. halt the device */ | ||||||
| 			mio_dev_halt ((mio_dev_t*)clidev); | 			MIO_DEBUG1 (mio, "SCK(%p) - ssl-accept timeout scheduling failed. halting\n", rdev); | ||||||
|  | 			mio_dev_sck_halt (clidev); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| @ -1597,7 +1607,7 @@ static int accept_incoming_connection (mio_dev_sck_t* rdev) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| accept_done: | accept_done: | ||||||
| 	return make_accepted_client_connection (rdev, clisck, &remoteaddr, rdev->type); | 	return make_accepted_client_connection(rdev, clisck, &remoteaddr, rdev->type); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int dev_evcb_sck_ready_stateful (mio_dev_t* dev, int events) | static int dev_evcb_sck_ready_stateful (mio_dev_t* dev, int events) | ||||||
| @ -1906,7 +1916,8 @@ static int dev_evcb_sck_on_read_qx (mio_dev_t* dev, const void* data, mio_iolen_ | |||||||
| 		if (dlen != MIO_SIZEOF(*qxmsg)) | 		if (dlen != MIO_SIZEOF(*qxmsg)) | ||||||
| 		{ | 		{ | ||||||
| 			mio_seterrbfmt (mio, MIO_EINVAL, "wrong qx packet size"); | 			mio_seterrbfmt (mio, MIO_EINVAL, "wrong qx packet size"); | ||||||
| 			return -1; | printf ("unable wrong packet size... \n"); | ||||||
|  | 			return 0; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		qxmsg = (mio_dev_sck_qxmsg_t*)data; | 		qxmsg = (mio_dev_sck_qxmsg_t*)data; | ||||||
| @ -1914,14 +1925,16 @@ static int dev_evcb_sck_on_read_qx (mio_dev_t* dev, const void* data, mio_iolen_ | |||||||
| 		{ | 		{ | ||||||
| 			if (make_accepted_client_connection(rdev, qxmsg->syshnd, &qxmsg->remoteaddr, qxmsg->scktype) <= -1)  | 			if (make_accepted_client_connection(rdev, qxmsg->syshnd, &qxmsg->remoteaddr, qxmsg->scktype) <= -1)  | ||||||
| 			{ | 			{ | ||||||
|  | printf ("unable to accept new client connection\n"); | ||||||
| 				close (qxmsg->syshnd); | 				close (qxmsg->syshnd); | ||||||
| 				return -1; | 				return -1; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
|  | printf ("unknown qx xommand code\n"); | ||||||
| 			mio_seterrbfmt (mio, MIO_EINVAL, "wrong qx command code"); | 			mio_seterrbfmt (mio, MIO_EINVAL, "wrong qx command code"); | ||||||
| 			return -1; | 			return 0; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return 0; | 		return 0; | ||||||
|  | |||||||
| @ -77,9 +77,10 @@ int mio_makesyshndasync (mio_t* mio, mio_syshnd_t hnd) | |||||||
| #if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) | #if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) | ||||||
| 	int flags; | 	int flags; | ||||||
|  |  | ||||||
| 	if ((flags = fcntl(hnd, F_GETFL)) <= -1 || | 	if ((flags = fcntl(hnd, F_GETFL, 0)) <= -1 || | ||||||
| 	    (flags = fcntl(hnd, F_SETFL, flags | O_NONBLOCK)) <= -1) | 	    fcntl(hnd, F_SETFL, flags | O_NONBLOCK) <= -1) | ||||||
| 	{ | 	{ | ||||||
|  | printf ("make sysnhd async error (%d)\n", hnd); | ||||||
| 		mio_seterrwithsyserr (mio, 0, errno); | 		mio_seterrwithsyserr (mio, 0, errno); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| @ -96,9 +97,10 @@ int mio_makesyshndcloexec (mio_t* mio, mio_syshnd_t hnd) | |||||||
| #if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC) | #if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC) | ||||||
| 	int flags; | 	int flags; | ||||||
|  |  | ||||||
| 	if ((flags = fcntl(hnd, F_GETFD)) <= -1 || | 	if ((flags = fcntl(hnd, F_GETFD, 0)) <= -1 || | ||||||
| 	    (flags = fcntl(hnd, F_SETFD, flags | FD_CLOEXEC)) <= -1) | 	    fcntl(hnd, F_SETFD, flags | FD_CLOEXEC) <= -1) | ||||||
| 	{ | 	{ | ||||||
|  | printf ("make sysnhd cloexec error (%d)\n", hnd); | ||||||
| 		mio_seterrwithsyserr (mio, 0, errno); | 		mio_seterrwithsyserr (mio, 0, errno); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user