Tcl Source Code

Check-in [2d07e770af]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Experiment, does this work? Still to be tested: Eliminate variable triggerPipeVal/eventFdVal (just use 'char dummy'), and just read/write 1 byte to triggerEventFd in stead of 8. Experiment failed: eventfd's always should be read/written 8 bytes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | tip-458-experiment
Files: files | file ages | folders
SHA1: 2d07e770af044abae6786352a7e396e678f591ee
User & Date: jan.nijtmans 2017-04-26 14:06:21
Original Comment: Experiment, does this work? Still to be tested: Eliminate variable triggerPipeVal/eventFdVal (just use 'char dummy'), and just read/write 1 byte to triggerEventFd in stead of 8.
Context
2017-04-26
14:06
Experiment, does this work? Still to be tested: Eliminate variable triggerPipeVal/eventFdVal (just u... Closed-Leaf check-in: 2d07e770af user: jan.nijtmans tags: tip-458-experiment
13:48
Move some variable declarations closer to where they are used. No change in functionality. check-in: cf831b219f user: jan.nijtmans tags: tip-458
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to unix/tclEpollNotfy.c.

743
744
745
746
747
748
749

750
751
752
753
754
755
756
757
758
759
760
761
762
763

764
765
766
767
768
769
770
	 * up this thread whilst it's blocking on PlatformEventsWait(), it
	 * write(2)s to the eventfd(2)/trigger pipe (see Tcl_AlertNotifier(),)
	 * which in turn will cause PlatformEventsWait() to return immediately.
	 */

	numFound = PlatformEventsWait(tsdPtr->readyEvents, tsdPtr->maxReadyEvents, timeoutPtr);
	for (numEvent = 0; numEvent < numFound; numEvent++) {

	    pedPtr = tsdPtr->readyEvents[numEvent].data.ptr;
	    filePtr = pedPtr->filePtr;
	    mask = PlatformEventsTranslate(&tsdPtr->readyEvents[numEvent]);
#ifdef HAVE_EVENTFD
	    if (filePtr->fd == tsdPtr->triggerEventFd) {
		uint64_t eventFdVal;
		i = read(tsdPtr->triggerEventFd, &eventFdVal, sizeof(eventFdVal));
		if ((i != sizeof(eventFdVal)) && (errno != EAGAIN)) {
#else
	    if (filePtr->fd == tsdPtr->triggerPipe[0]) {
		char triggerPipeVal;
		i = read(tsdPtr->triggerPipe[0], &triggerPipeVal, sizeof(triggerPipeVal));
		if ((i != sizeof(triggerPipeVal)) && (errno != EAGAIN)) {
#endif

			Tcl_Panic("Tcl_WaitForEvent: "
				"read from %p->triggerEventFd: %s",
				(void *)tsdPtr, strerror(errno));
		} else {
		    continue;
		}
	    }







>





<
|
<


<
|
<

>







743
744
745
746
747
748
749
750
751
752
753
754
755

756

757
758

759

760
761
762
763
764
765
766
767
768
	 * up this thread whilst it's blocking on PlatformEventsWait(), it
	 * write(2)s to the eventfd(2)/trigger pipe (see Tcl_AlertNotifier(),)
	 * which in turn will cause PlatformEventsWait() to return immediately.
	 */

	numFound = PlatformEventsWait(tsdPtr->readyEvents, tsdPtr->maxReadyEvents, timeoutPtr);
	for (numEvent = 0; numEvent < numFound; numEvent++) {
	    char dummy;
	    pedPtr = tsdPtr->readyEvents[numEvent].data.ptr;
	    filePtr = pedPtr->filePtr;
	    mask = PlatformEventsTranslate(&tsdPtr->readyEvents[numEvent]);
#ifdef HAVE_EVENTFD
	    if (filePtr->fd == tsdPtr->triggerEventFd) {

		i = read(tsdPtr->triggerEventFd, &dummy, 1);

#else
	    if (filePtr->fd == tsdPtr->triggerPipe[0]) {

		i = read(tsdPtr->triggerPipe[0], &dummy, 1);

#endif
		if ((i != 1) && (errno != EAGAIN)) {
			Tcl_Panic("Tcl_WaitForEvent: "
				"read from %p->triggerEventFd: %s",
				(void *)tsdPtr, strerror(errno));
		} else {
		    continue;
		}
	    }

Changes to unix/tclUnixNotfy.c.

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
	pthread_cond_broadcast(&tsdPtr->waitCV);
#   endif /* __CYGWIN__ */
	pthread_mutex_unlock(&notifierMutex);
#endif /* TCL_THREADS */
#else
	ThreadSpecificData *tsdPtr = clientData;
#if defined(NOTIFIER_EPOLL) && defined(HAVE_EVENTFD)
	uint64_t eventFdVal = 1;
	if (write(tsdPtr->triggerEventFd, &eventFdVal,
		sizeof(eventFdVal)) != sizeof(eventFdVal)) {
	    Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerEventFd",
		(void *)tsdPtr);
#else
	if (write(tsdPtr->triggerPipe[1], "", 1) != 1) {
	    Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerPipe",
		(void *)tsdPtr);
#endif /* NOTIFIER_EPOLL && HAVE_EVENTFD */







<
|
<







119
120
121
122
123
124
125

126

127
128
129
130
131
132
133
	pthread_cond_broadcast(&tsdPtr->waitCV);
#   endif /* __CYGWIN__ */
	pthread_mutex_unlock(&notifierMutex);
#endif /* TCL_THREADS */
#else
	ThreadSpecificData *tsdPtr = clientData;
#if defined(NOTIFIER_EPOLL) && defined(HAVE_EVENTFD)

	if (write(tsdPtr->triggerEventFd, "", 1) != 1) {

	    Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerEventFd",
		(void *)tsdPtr);
#else
	if (write(tsdPtr->triggerPipe[1], "", 1) != 1) {
	    Tcl_Panic("Tcl_AlertNotifier: unable to write to %p->triggerPipe",
		(void *)tsdPtr);
#endif /* NOTIFIER_EPOLL && HAVE_EVENTFD */