Tcl Source Code

Check-in [8cec831ad2]
Login

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

Overview
Comment:move pthread_sigmask() calls to Tcl_WaitForEvent() where they belong
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | bug-f4f44174e
Files: files | file ages | folders
SHA1: 8cec831ad2b67f9634f83a8f3363654845d6451e
User & Date: aspect 2016-12-06 21:52:29
Context
2016-12-06
21:52
move pthread_sigmask() calls to Tcl_WaitForEvent() where they belong Leaf check-in: 8cec831ad2 user: aspect tags: bug-f4f44174e
21:51
unblock signals correctly with SIG_SETMASK check-in: ae3cf707c1 user: aspect tags: bug-f4f44174e
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to unix/tclUnixNotfy.c.

487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
    ClientData clientData)
{
    if (tclNotifierHooks.alertNotifierProc) {
	tclNotifierHooks.alertNotifierProc(clientData);
	return;
    } else {
#ifdef TCL_THREADS
	sigset_t sigset, oldset;
	ThreadSpecificData *tsdPtr = clientData;

	/* block signals while we're holding the mutex */
	sigfillset(&sigset);
	pthread_sigmask(SIG_BLOCK, &sigset, &oldset);

	pthread_mutex_lock(&notifierMutex);
	tsdPtr->eventReady = 1;

#   ifdef __CYGWIN__
	PostMessageW(tsdPtr->hwnd, 1024, 0, 0);
#   else
	pthread_cond_broadcast(&tsdPtr->waitCV);
#   endif /* __CYGWIN__ */
	pthread_mutex_unlock(&notifierMutex);

	/* unblock signals */
	pthread_sigmask(SIG_SETMASK, &oldset, NULL);

#endif /* TCL_THREADS */
    }
}

/*
 *----------------------------------------------------------------------
 *







<


<
<
<
<










<
<
<







487
488
489
490
491
492
493

494
495




496
497
498
499
500
501
502
503
504
505



506
507
508
509
510
511
512
    ClientData clientData)
{
    if (tclNotifierHooks.alertNotifierProc) {
	tclNotifierHooks.alertNotifierProc(clientData);
	return;
    } else {
#ifdef TCL_THREADS

	ThreadSpecificData *tsdPtr = clientData;





	pthread_mutex_lock(&notifierMutex);
	tsdPtr->eventReady = 1;

#   ifdef __CYGWIN__
	PostMessageW(tsdPtr->hwnd, 1024, 0, 0);
#   else
	pthread_cond_broadcast(&tsdPtr->waitCV);
#   endif /* __CYGWIN__ */
	pthread_mutex_unlock(&notifierMutex);




#endif /* TCL_THREADS */
    }
}

/*
 *----------------------------------------------------------------------
 *
869
870
871
872
873
874
875

876
877
878
879
880
881
882
	return tclNotifierHooks.waitForEventProc(timePtr);
    } else {
	FileHandler *filePtr;
	int mask;
	Tcl_Time vTime;
#ifdef TCL_THREADS
	int waitForFiles;

#   ifdef __CYGWIN__
	MSG msg;
#   endif /* __CYGWIN__ */
#else
	/*
	 * Impl. notes: timeout & timeoutPtr are used if, and only if threads
	 * are not enabled. They are the arguments for the regular select()







>







861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
	return tclNotifierHooks.waitForEventProc(timePtr);
    } else {
	FileHandler *filePtr;
	int mask;
	Tcl_Time vTime;
#ifdef TCL_THREADS
	int waitForFiles;
	sigset_t sigset, oldset;
#   ifdef __CYGWIN__
	MSG msg;
#   endif /* __CYGWIN__ */
#else
	/*
	 * Impl. notes: timeout & timeoutPtr are used if, and only if threads
	 * are not enabled. They are the arguments for the regular select()
929
930
931
932
933
934
935



936
937
938
939
940
941
942
	/*
	 * Start notifier thread and place this thread on the list of
	 * interested threads, signal the notifier thread, and wait for a
	 * response or a timeout.
	 */
	StartNotifierThread("Tcl_WaitForEvent");




	pthread_mutex_lock(&notifierMutex);

	if (timePtr != NULL && timePtr->sec == 0 && (timePtr->usec == 0
#if defined(__APPLE__) && defined(__LP64__)
		/*
		 * On 64-bit Darwin, pthread_cond_timedwait() appears to have
		 * a bug that causes it to wait forever when passed an







>
>
>







922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
	/*
	 * Start notifier thread and place this thread on the list of
	 * interested threads, signal the notifier thread, and wait for a
	 * response or a timeout.
	 */
	StartNotifierThread("Tcl_WaitForEvent");

	/* block signals while we're holding the mutex */
	sigfillset(&sigset);
	pthread_sigmask(SIG_BLOCK, &sigset, &oldset);
	pthread_mutex_lock(&notifierMutex);

	if (timePtr != NULL && timePtr->sec == 0 && (timePtr->usec == 0
#if defined(__APPLE__) && defined(__LP64__)
		/*
		 * On 64-bit Darwin, pthread_cond_timedwait() appears to have
		 * a bug that causes it to wait forever when passed an
1114
1115
1116
1117
1118
1119
1120


1121
1122
1123
1124
1125
1126
1127
		fileEvPtr->fd = filePtr->fd;
		Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL);
	    }
	    filePtr->readyMask = mask;
	}
#ifdef TCL_THREADS
	pthread_mutex_unlock(&notifierMutex);


#endif /* TCL_THREADS */
	return 0;
    }
}

#ifdef TCL_THREADS
/*







>
>







1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
		fileEvPtr->fd = filePtr->fd;
		Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL);
	    }
	    filePtr->readyMask = mask;
	}
#ifdef TCL_THREADS
	pthread_mutex_unlock(&notifierMutex);
	/* unblock signals */
 	pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif /* TCL_THREADS */
	return 0;
    }
}

#ifdef TCL_THREADS
/*