[INTERPRETER]

* BUG: Don't remove the possible watch when freeing the file. The file may 
  be closed, and the file descritor may have been reused!


git-svn-id: svn://localhost/gambas/trunk@6693 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-12-01 02:50:18 +00:00
parent 1a2901e961
commit 1fcb7bd02e
4 changed files with 15 additions and 30 deletions

View file

@ -59,7 +59,6 @@ static char _buffer[16];
static void callback_read(int fd, int type, CFILE *file)
{
//fprintf(stderr, "callback_read\n");
GB_Raise(file, EVENT_Read, 0);
}
@ -147,9 +146,6 @@ BEGIN_METHOD_VOID(File_free)
STREAM_close(&THIS->ob.stream);
if (THIS->watch_fd >= 0)
GB_Watch(THIS->watch_fd, GB_WATCH_NONE, NULL, 0);
END_METHOD

View file

@ -140,10 +140,7 @@ static int stream_read(STREAM *stream, char *buffer, int len)
return STREAM_read_direct(FD, buffer, len);
}
static int stream_getchar(STREAM *stream, char *buffer)
{
return read(FD, buffer, 1) <= 0;
}
#define stream_getchar NULL
static int stream_write(STREAM *stream, char *buffer, int len)

View file

@ -88,10 +88,7 @@ static int stream_read(STREAM *stream, char *buffer, int len)
return STREAM_read_direct(FD, buffer, len);
}
static int stream_getchar(STREAM *stream, char *buffer)
{
return read(FD, buffer, 1) <= 0;
}
#define stream_getchar NULL
static int stream_write(STREAM *stream, char *buffer, int len)
@ -118,23 +115,8 @@ static int stream_flush(STREAM *stream)
}
/*static int stream_eof(STREAM *stream)
{
int ilen;
if (STREAM_get_readable(FD, &ilen))
return TRUE;
return (ilen == 0);
}*/
#define stream_eof NULL
/*static int stream_lof(STREAM *stream, int64_t *len)
{
*len = 0;
return FALSE;
}*/
#define stream_lof NULL

View file

@ -286,7 +286,7 @@ void WATCH_exit(void)
static void watch_fd(int fd, int flag, bool watch)
{
#if DEBUG_WATCH
fprintf(stderr, "watch_fd: %d for %s: %s\n", fd, flag == WATCH_READ ? "read" : "write", watch ? "set" : "clear");
fprintf(stderr, "watch_fd: %d for %s: %s\n", fd, flag == GB_WATCH_READ ? "read" : "write", watch ? "set" : "clear");
#endif
if (flag == GB_WATCH_READ)
@ -394,9 +394,9 @@ static void watch_delete_callback(int fd)
pos = watch_find_callback(fd);
if (pos < 0)
return;
//watch_index[fd] = -1;
wcb = &watch_callback[pos];
wcb->fd = -1;
watch_fd(fd, GB_WATCH_READ, FALSE);
@ -405,11 +405,18 @@ static void watch_delete_callback(int fd)
if (_do_not_really_delete_callback)
{
#if DEBUG_WATCH
fprintf(stderr, "--> do not really delete\n");
#endif
_must_delete_callback = TRUE;
return;
}
ARRAY_remove(&watch_callback, pos);
#if DEBUG_WATCH
fprintf(stderr, "--> deleted\n");
#endif
}
@ -508,6 +515,9 @@ static void raise_callback(fd_set *rfd, fd_set *wfd)
if (!_do_not_really_delete_callback && _must_delete_callback)
{
#if DEBUG_WATCH
fprintf(stderr, "do must delete callback\n");
#endif
i = 0;
while (i < ARRAY_count(watch_callback))
{