aboutsummaryrefslogtreecommitdiff
path: root/jim-eventloop.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-09-10 15:15:04 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:51 +1000
commit38733caf6dc5e8556283c62468d0b3f20d5911dd (patch)
tree6b527d13a02bcfdfaf0c98daa321f6da0167d7f3 /jim-eventloop.c
parentfe33a846cd13edf9440b81756896105ab4a86680 (diff)
downloadjimtcl-38733caf6dc5e8556283c62468d0b3f20d5911dd.zip
jimtcl-38733caf6dc5e8556283c62468d0b3f20d5911dd.tar.gz
jimtcl-38733caf6dc5e8556283c62468d0b3f20d5911dd.tar.bz2
Fix some eventloop problems
File handlers now pass through the error code and the handler is deleted on error. If there is nothing to do, vwait returns. If bgerror doesn't exist, print the original error to stderr. Also remove the 'eof' event handler since it isn't needed. Can just call [eof $f]. This also fixes source locations within 'readable' scripts. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-eventloop.c')
-rw-r--r--jim-eventloop.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/jim-eventloop.c b/jim-eventloop.c
index 7c17ec8..ec8bfd1 100644
--- a/jim-eventloop.c
+++ b/jim-eventloop.c
@@ -236,7 +236,9 @@ static Jim_TimeEvent *JimSearchNearestTimer(Jim_EventLoop * eventLoop)
* if flags has JIM_DONT_WAIT set the function returns ASAP until all
* the events that's possible to process without to wait are processed.
*
- * The function returns the number of events processed. */
+ * The function returns the number of events processed or -1 if
+ * there are no matching handlers
+ */
int Jim_ProcessEvents(Jim_Interp *interp, int flags)
{
int maxfd = 0, numfd = 0, processed = 0;
@@ -246,7 +248,13 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
Jim_TimeEvent *te;
jim_wide maxId;
- JIM_NOTUSED(flags);
+ if ((flags & JIM_FILE_EVENTS) == 0 || fe == NULL) {
+ /* No file events */
+ if ((flags & JIM_TIME_EVENTS) == 0 || eventLoop->timeEventHead == NULL) {
+ /* No time events */
+ return -1;
+ }
+ }
FD_ZERO(&rfds);
FD_ZERO(&wfds);
@@ -321,7 +329,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
mask |= JIM_EVENT_WRITABLE;
if (fe->mask & JIM_EVENT_EXCEPTION && FD_ISSET(fd, &efds))
mask |= JIM_EVENT_EXCEPTION;
- if (fe->fileProc(interp, fe->clientData, mask) == JIM_ERR) {
+ if (fe->fileProc(interp, fe->clientData, mask) != JIM_OK) {
/* Remove the element on handler error */
Jim_DeleteFileHandler(interp, fe->handle);
}
@@ -417,7 +425,10 @@ static int JimELVwaitCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
while (1) {
Jim_Obj *currValue;
- Jim_ProcessEvents(interp, JIM_ALL_EVENTS);
+ if (Jim_ProcessEvents(interp, JIM_ALL_EVENTS) < 0) {
+ /* Nothing level to process */
+ break;
+ }
currValue = Jim_GetGlobalVariable(interp, argv[1], JIM_NONE);
/* Stop the loop if the vwait-ed variable changed value,
* or if was unset and now is set (or the contrary). */