Commit 81ad1bb2 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Fix double close of file descriptor on error. (#82139, Wayne Schuller)

Mon May 20 15:35:59 2002  Owen Taylor  <otaylor@redhat.com>

        * glib/gfileutils.c (get_contents_regfile): Fix double
        close of file descriptor on error. (#82139, Wayne Schuller)

        * glib/gspawn.c (close_and_invalidate): Don't close
        fd's that have already been closed. (Fix from Michael
        Meeks, #81959)

        * glib/giochannel.c (g_io_channel_close): If not flushing,
        dump the contents of the write buffers, so we won't try
        to write them to an invalid fd later. (Patch from Ron Steinke,
        fixing #78290, Andreas Persenius.)
parent 60f59976
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
Mon May 20 15:35:59 2002 Owen Taylor <otaylor@redhat.com>
* glib/gfileutils.c (get_contents_regfile): Fix double
close of file descriptor on error. (#82139, Wayne Schuller)
* glib/gspawn.c (close_and_invalidate): Don't close
fd's that have already been closed. (Fix from Michael
Meeks, #81959)
* glib/giochannel.c (g_io_channel_close): If not flushing,
dump the contents of the write buffers, so we won't try
to write them to an invalid fd later. (Patch from Ron Steinke,
fixing #78290, Andreas Persenius.)
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
......
......@@ -416,8 +416,6 @@ get_contents_regfile (const gchar *filename,
{
if (errno != EINTR)
{
close (fd);
g_free (buf);
g_set_error (error,
......
......@@ -346,27 +346,35 @@ g_io_channel_shutdown (GIOChannel *channel,
g_return_val_if_fail (channel != NULL, G_IO_STATUS_ERROR);
g_return_val_if_fail (err == NULL || *err == NULL, G_IO_STATUS_ERROR);
if (flush && channel->write_buf && channel->write_buf->len > 0)
if (channel->write_buf && channel->write_buf->len > 0)
{
GIOFlags flags;
if (flush)
{
GIOFlags flags;
/* Set the channel to blocking, to avoid a busy loop
*/
flags = g_io_channel_get_flags (channel);
/* Ignore any errors here, they're irrelevant */
g_io_channel_set_flags (channel, flags & ~G_IO_FLAG_NONBLOCK, NULL);
result = g_io_channel_flush (channel, &tmperr);
/* Set the channel to blocking, to avoid a busy loop
*/
flags = g_io_channel_get_flags (channel);
/* Ignore any errors here, they're irrelevant */
g_io_channel_set_flags (channel, flags & ~G_IO_FLAG_NONBLOCK, NULL);
if (channel->partial_write_buf[0] != '\0')
{
g_warning ("Partial character at end of write buffer not flushed.\n");
channel->partial_write_buf[0] = '\0';
result = g_io_channel_flush (channel, &tmperr);
}
else
result = G_IO_STATUS_NORMAL;
g_string_truncate(channel->write_buf, 0);
}
else
result = G_IO_STATUS_NORMAL;
if (channel->partial_write_buf[0] != '\0')
{
if (flush)
g_warning ("Partial character at end of write buffer not flushed.\n");
channel->partial_write_buf[0] = '\0';
}
status = channel->funcs->io_close (channel, err);
channel->close_on_unref = FALSE; /* Because we already did */
......
......@@ -119,8 +119,13 @@ close_and_invalidate (gint *fd)
{
gint ret;
ret = close (*fd);
*fd = -1;
if (*fd < 0)
return -1;
else
{
ret = close (*fd);
*fd = -1;
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment