mirror of https://github.com/GNOME/gimp.git
merged fix for bug #85573 from stable branch. We should port this stuff to
2002-06-17 Sven Neumann <sven@gimp.org> * plug-ins/script-fu/script-fu-server.c (read_from_client): merged fix for bug #85573 from stable branch. We should port this stuff to use GIOChannels.
This commit is contained in:
parent
a3f44d8b0f
commit
29c36954f5
|
@ -1,3 +1,9 @@
|
|||
2002-06-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/script-fu-server.c (read_from_client): merged
|
||||
fix for bug #85573 from stable branch. We should port this stuff
|
||||
to use GIOChannels.
|
||||
|
||||
2002-06-17 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Separated tool_options creation from tool registration so we
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -431,17 +432,23 @@ read_from_client (gint filedes)
|
|||
gint nbytes;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < COMMAND_HEADER; i++)
|
||||
for (i = 0; i < COMMAND_HEADER;)
|
||||
{
|
||||
if ((nbytes = read (filedes, buffer + i, 1)) < 0)
|
||||
{
|
||||
/* Read error. */
|
||||
perror ("read");
|
||||
return 0;
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
/* End-of-file. */
|
||||
return -1;
|
||||
nbytes = read (filedes, buffer + i, COMMAND_HEADER - i);
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
server_log ("Error reading command header.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nbytes == 0)
|
||||
return -1; /* EOF */
|
||||
|
||||
i += nbytes;
|
||||
}
|
||||
|
||||
if (buffer[MAGIC_BYTE] != MAGIC)
|
||||
|
@ -453,13 +460,23 @@ read_from_client (gint filedes)
|
|||
command_len = (buffer [CMD_LEN_H_BYTE] << 8) | buffer [CMD_LEN_L_BYTE];
|
||||
command = g_new (gchar, command_len + 1);
|
||||
|
||||
for (i = 0; i < command_len; i++)
|
||||
if (read (filedes, command + i, 1) == 0)
|
||||
{
|
||||
server_log ("Error reading command. Read %d out of %d bytes.\n",
|
||||
i, command_len);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < command_len;)
|
||||
{
|
||||
nbytes = read (filedes, command + i, command_len - i);
|
||||
|
||||
if (nbytes <= 0)
|
||||
{
|
||||
if (nbytes < 0 && errno == EINTR)
|
||||
continue;
|
||||
|
||||
server_log ("Error reading command. Read %d out of %d bytes.\n",
|
||||
i, command_len);
|
||||
g_free (command);
|
||||
return -1;
|
||||
}
|
||||
|
||||
i += nbytes;
|
||||
}
|
||||
|
||||
command[command_len] = '\0';
|
||||
cmd = g_new (SFCommand, 1);
|
||||
|
|
Loading…
Reference in New Issue