2003-06-08 Tor Lillqvist <tml@iki.fi>
* glib/giowin32.c: Fix indentation and spacing. Use
INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
gethostbyaddr().
+2003-06-08 Tor Lillqvist <tml@iki.fi>
+
+ * glib/giowin32.c: Fix indentation and spacing. Use
+ INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
+ gethostbyaddr().
+
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
+2003-06-08 Tor Lillqvist <tml@iki.fi>
+
+ * glib/giowin32.c: Fix indentation and spacing. Use
+ INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
+ gethostbyaddr().
+
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
+2003-06-08 Tor Lillqvist <tml@iki.fi>
+
+ * glib/giowin32.c: Fix indentation and spacing. Use
+ INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
+ gethostbyaddr().
+
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
+2003-06-08 Tor Lillqvist <tml@iki.fi>
+
+ * glib/giowin32.c: Fix indentation and spacing. Use
+ INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
+ gethostbyaddr().
+
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
+2003-06-08 Tor Lillqvist <tml@iki.fi>
+
+ * glib/giowin32.c: Fix indentation and spacing. Use
+ INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
+ gethostbyaddr().
+
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
+2003-06-08 Tor Lillqvist <tml@iki.fi>
+
+ * glib/giowin32.c: Fix indentation and spacing. Use
+ INADDR_LOOPBACK instead of inet_addr("127.0.0.1") and
+ gethostbyaddr().
+
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
Sat Jun 6 16:18:10 2003 Andrew Lanoix <alanoix@umich.edu>
* glib/giowin32.c: Resolved thread deadlocks in socket
SetEvent (channel->data_avail_event);
UNLOCK (channel->mutex);
SetEvent (channel->data_avail_event);
UNLOCK (channel->mutex);
- g_io_channel_unref((GIOChannel *)channel);
+ g_io_channel_unref ((GIOChannel *)channel);
/* No need to call _endthreadex(), the actual thread starter routine
* in MSVCRT (see crt/src/threadex.c:_threadstartex) calls
/* No need to call _endthreadex(), the actual thread starter routine
* in MSVCRT (see crt/src/threadex.c:_threadstartex) calls
-init_reset_sockets(GIOWin32Channel *channel)
+init_reset_sockets (GIOWin32Channel *channel)
{
struct sockaddr_in local, local2, server;
{
struct sockaddr_in local, local2, server;
- channel->reset_send = (gint) socket(AF_INET, SOCK_DGRAM, 0);
+ channel->reset_send = (gint) socket (AF_INET, SOCK_DGRAM, 0);
if (channel->reset_send == INVALID_SOCKET)
if (channel->reset_send == INVALID_SOCKET)
- {
- g_warning (G_STRLOC ": Error creating reset_send socket: %s\n",
- g_win32_error_message (WSAGetLastError ()));
- }
+ {
+ g_warning (G_STRLOC ": Error creating reset_send socket: %s\n",
+ g_win32_error_message (WSAGetLastError ()));
+ }
local.sin_family = AF_INET;
local.sin_port = 0;
local.sin_family = AF_INET;
local.sin_port = 0;
- local.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
+ local.sin_addr.s_addr = htonl (INADDR_ANY);
- if (bind(channel->reset_send, (struct sockaddr *)&local, sizeof(local)) == SOCKET_ERROR)
- {
- g_warning (G_STRLOC ": Error binding to reset_send socket: %s\n",
- g_win32_error_message (WSAGetLastError ()));
+ if (bind (channel->reset_send, (struct sockaddr *)&local, sizeof (local)) == SOCKET_ERROR)
+ {
+ g_warning (G_STRLOC ": Error binding to reset_send socket: %s\n",
+ g_win32_error_message (WSAGetLastError ()));
}
local2.sin_family = AF_INET;
local2.sin_port = 0;
}
local2.sin_family = AF_INET;
local2.sin_port = 0;
- local2.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
+ local2.sin_addr.s_addr = htonl (INADDR_ANY);
- channel->reset_recv = (gint) socket(AF_INET, SOCK_DGRAM, 0);
+ channel->reset_recv = (gint) socket (AF_INET, SOCK_DGRAM, 0);
if (channel->reset_recv == INVALID_SOCKET)
if (channel->reset_recv == INVALID_SOCKET)
- {
- g_warning (G_STRLOC ": Error creating reset_recv socket: %s\n",
- g_win32_error_message (WSAGetLastError ()));
+ {
+ g_warning (G_STRLOC ": Error creating reset_recv socket: %s\n",
+ g_win32_error_message (WSAGetLastError ()));
- if (bind(channel->reset_recv, (struct sockaddr *)&local2, sizeof(local)) == SOCKET_ERROR)
- {
- g_warning (G_STRLOC ": Error binding to reset_recv socket: %s\n",
- g_win32_error_message (WSAGetLastError ()));
- }
+ if (bind (channel->reset_recv, (struct sockaddr *)&local2, sizeof (local)) == SOCKET_ERROR)
+ {
+ g_warning (G_STRLOC ": Error binding to reset_recv socket: %s\n",
+ g_win32_error_message (WSAGetLastError ()));
+ }
- len = sizeof(local2);
- if (getsockname(channel->reset_recv, (struct sockaddr *)&local2, &len) == SOCKET_ERROR)
- {
- g_warning (G_STRLOC ": Error getsockname with reset_recv socket: %s\n",
- g_win32_error_message (WSAGetLastError ()));
- }
-
- addr = inet_addr("127.0.0.1");
- hp = gethostbyaddr((char *)&addr,4,AF_INET);
+ len = sizeof (local2);
+ if (getsockname (channel->reset_recv, (struct sockaddr *)&local2, &len) == SOCKET_ERROR)
+ {
+ g_warning (G_STRLOC ": Error getsockname with reset_recv socket: %s\n",
+ g_win32_error_message (WSAGetLastError ()));
+ }
- memset(&server,0,sizeof(server));
- memcpy(&(server.sin_addr),hp->h_addr,hp->h_length);
- server.sin_family = hp->h_addrtype;
+ memset (&server, 0, sizeof (server));
+ server.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+ server.sin_family = AF_INET;
server.sin_port = local2.sin_port;
server.sin_port = local2.sin_port;
- if (connect(channel->reset_send, (struct sockaddr *)&server, sizeof(server)) == SOCKET_ERROR)
- {
- g_warning (G_STRLOC ": connect to reset_recv socket: %s\n",
- g_win32_error_message (WSAGetLastError ()));
+ if (connect (channel->reset_send, (struct sockaddr *)&server, sizeof (server)) == SOCKET_ERROR)
+ {
+ g_warning (G_STRLOC ": connect to reset_recv socket: %s\n",
+ g_win32_error_message (WSAGetLastError ()));
FD_ZERO (&read_fds);
FD_ZERO (&write_fds);
FD_ZERO (&except_fds);
FD_ZERO (&read_fds);
FD_ZERO (&write_fds);
FD_ZERO (&except_fds);
- FD_SET(channel->reset_recv, &read_fds);
+ FD_SET (channel->reset_recv, &read_fds);
LOCK (channel->mutex);
tmp = channel->watches;
while (tmp)
LOCK (channel->mutex);
tmp = channel->watches;
while (tmp)
- {
- GIOWin32Watch *watch = (GIOWin32Watch *)tmp->data;
-
- if (watch->condition & (G_IO_IN | G_IO_HUP))
- FD_SET (channel->fd, &read_fds);
- if (watch->condition & G_IO_OUT)
- FD_SET (channel->fd, &write_fds);
- if (watch->condition & G_IO_ERR)
- FD_SET (channel->fd, &except_fds);
+ {
+ GIOWin32Watch *watch = (GIOWin32Watch *)tmp->data;
+
+ if (watch->condition & (G_IO_IN | G_IO_HUP))
+ FD_SET (channel->fd, &read_fds);
+ if (watch->condition & G_IO_OUT)
+ FD_SET (channel->fd, &write_fds);
+ if (watch->condition & G_IO_ERR)
+ FD_SET (channel->fd, &except_fds);
UNLOCK (channel->mutex);
if (channel->debug)
UNLOCK (channel->mutex);
if (channel->debug)
- g_print ("select_thread %#x: calling select() for%s%s%s\n",
- channel->thread_id,
- (FD_ISSET (channel->fd, &read_fds) ? " IN" : ""),
- (FD_ISSET (channel->fd, &write_fds) ? " OUT" : ""),
- (FD_ISSET (channel->fd, &except_fds) ? " ERR" : ""));
-
+ g_print ("select_thread %#x: calling select() for%s%s%s\n",
+ channel->thread_id,
+ (FD_ISSET (channel->fd, &read_fds) ? " IN" : ""),
+ (FD_ISSET (channel->fd, &write_fds) ? " OUT" : ""),
+ (FD_ISSET (channel->fd, &except_fds) ? " ERR" : ""));
+
n = select (1, &read_fds, &write_fds, &except_fds, NULL);
n = select (1, &read_fds, &write_fds, &except_fds, NULL);
if (channel->needs_close)
if (channel->needs_close)
- {
- UNLOCK (channel->mutex);
- break;
- }
+ {
+ UNLOCK (channel->mutex);
+ break;
+ }
UNLOCK (channel->mutex);
if (n == SOCKET_ERROR)
UNLOCK (channel->mutex);
if (n == SOCKET_ERROR)
- if (FD_ISSET(channel->reset_recv, &read_fds))
+ if (FD_ISSET (channel->reset_recv, &read_fds))
{
if (channel->debug)
g_print ("select_thread %#x: re-looping\n",
channel->thread_id);
{
if (channel->debug)
g_print ("select_thread %#x: re-looping\n",
channel->thread_id);
- recv(channel->reset_recv, (char *)&buffer, (int) sizeof(buffer), 0);
+ recv (channel->reset_recv, (char *)&buffer, (int) sizeof (buffer), 0);
continue;
}
if (channel->debug)
continue;
}
if (channel->debug)
- g_print ("select_thread %#x: got%s%s%s\n",
- channel->thread_id,
- (FD_ISSET (channel->fd, &read_fds) ? " IN" : ""),
- (FD_ISSET (channel->fd, &write_fds) ? " OUT" : ""),
- (FD_ISSET (channel->fd, &except_fds) ? " ERR" : ""));
-
+ g_print ("select_thread %#x: got%s%s%s\n",
+ channel->thread_id,
+ (FD_ISSET (channel->fd, &read_fds) ? " IN" : ""),
+ (FD_ISSET (channel->fd, &write_fds) ? " OUT" : ""),
+ (FD_ISSET (channel->fd, &except_fds) ? " ERR" : ""));
+
if (FD_ISSET (channel->fd, &read_fds))
channel->revents |= G_IO_IN;
if (FD_ISSET (channel->fd, &write_fds))
if (FD_ISSET (channel->fd, &read_fds))
channel->revents |= G_IO_IN;
if (FD_ISSET (channel->fd, &write_fds))
if (channel->debug)
g_print ("select_thread %#x: resetting data_avail_noticed, setting data_avail\n",
if (channel->debug)
g_print ("select_thread %#x: resetting data_avail_noticed, setting data_avail\n",
LOCK (channel->mutex);
ResetEvent (channel->data_avail_noticed_event);
SetEvent (channel->data_avail_event);
if (channel->needs_close)
LOCK (channel->mutex);
ResetEvent (channel->data_avail_noticed_event);
SetEvent (channel->data_avail_event);
if (channel->needs_close)
- {
- UNLOCK (channel->mutex);
- break;
- }
+ {
+ UNLOCK (channel->mutex);
+ break;
+ }
UNLOCK (channel->mutex);
if (channel->debug)
UNLOCK (channel->mutex);
if (channel->debug)
g_print ("select_thread %#x: got error, setting data_avail\n",
channel->thread_id);
SetEvent (channel->data_avail_event);
g_print ("select_thread %#x: got error, setting data_avail\n",
channel->thread_id);
SetEvent (channel->data_avail_event);
- g_io_channel_unref((GIOChannel *)channel);
+ g_io_channel_unref ((GIOChannel *)channel);
UNLOCK (channel->mutex);
/* No need to call _endthreadex(), the actual thread starter routine
UNLOCK (channel->mutex);
/* No need to call _endthreadex(), the actual thread starter routine
SetEvent (channel->data_avail_noticed_event);
if (channel->type == G_IO_WIN32_SOCKET)
SetEvent (channel->data_avail_noticed_event);
if (channel->type == G_IO_WIN32_SOCKET)
- send(channel->reset_send, send_buffer, sizeof(send_buffer), 0);
+ send (channel->reset_send, send_buffer, sizeof (send_buffer), 0);
g_io_channel_unref (watch->channel);
UNLOCK (channel->mutex);
g_io_channel_unref (watch->channel);
UNLOCK (channel->mutex);
if (win32_channel->thread_id == 0)
create_thread (win32_channel, condition, thread);
else
if (win32_channel->thread_id == 0)
create_thread (win32_channel, condition, thread);
else
- send(win32_channel->reset_send, send_buffer, sizeof(send_buffer), 0);
+ send (win32_channel->reset_send, send_buffer, sizeof (send_buffer), 0);
g_source_add_poll (source, &watch->pollfd);
UNLOCK (win32_channel->mutex);
g_source_add_poll (source, &watch->pollfd);
UNLOCK (win32_channel->mutex);
if (count < sizeof (MSG))
{
if (count < sizeof (MSG))
{
- g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
- "Incorrect message size"); /* Informative enough error message? */
+ g_set_error (err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
+ "Incorrect message size"); /* Informative enough error message? */
return G_IO_STATUS_ERROR;
}
return G_IO_STATUS_ERROR;
}
if (count != sizeof (MSG))
{
if (count != sizeof (MSG))
{
- g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
- "Incorrect message size"); /* Informative enough error message? */
+ g_set_error (err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
+ "Incorrect message size"); /* Informative enough error message? */
return G_IO_STATUS_ERROR;
}
return G_IO_STATUS_ERROR;
}
if (!PostMessage (win32_channel->hwnd, msg.message, msg.wParam, msg.lParam))
{
gchar *emsg = g_win32_error_message (GetLastError ());
if (!PostMessage (win32_channel->hwnd, msg.message, msg.wParam, msg.lParam))
{
gchar *emsg = g_win32_error_message (GetLastError ());
- g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, emsg);
+ g_set_error (err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, emsg);
g_free (emsg);
return G_IO_STATUS_ERROR;
}
g_free (emsg);
return G_IO_STATUS_ERROR;
}
win32_channel->fd);
if (win32_channel->reset_send)
win32_channel->fd);
if (win32_channel->reset_send)
- closesocket(win32_channel->reset_send);
+ closesocket (win32_channel->reset_send);
if (win32_channel->reset_recv)
if (win32_channel->reset_recv)
- closesocket(win32_channel->reset_recv);
+ closesocket (win32_channel->reset_recv);
if (win32_channel->data_avail_event)
CloseHandle (win32_channel->data_avail_event);
if (win32_channel->space_avail_event)
if (win32_channel->data_avail_event)
CloseHandle (win32_channel->data_avail_event);
if (win32_channel->space_avail_event)
- case EAGAIN:
- return G_IO_STATUS_AGAIN;
+ case EAGAIN:
+ return G_IO_STATUS_AGAIN;
- default:
- g_set_error (err, G_IO_CHANNEL_ERROR,
- g_io_channel_error_from_errno (errno),
- g_strerror (errno));
- return G_IO_STATUS_ERROR;
+ default:
+ g_set_error (err, G_IO_CHANNEL_ERROR,
+ g_io_channel_error_from_errno (errno),
+ g_strerror (errno));
+ return G_IO_STATUS_ERROR;
- case EAGAIN:
- return G_IO_STATUS_AGAIN;
+ case EAGAIN:
+ return G_IO_STATUS_AGAIN;
- default:
- g_set_error (err, G_IO_CHANNEL_ERROR,
- g_io_channel_error_from_errno (errno),
- g_strerror (errno));
- return G_IO_STATUS_ERROR;
+ default:
+ g_set_error (err, G_IO_CHANNEL_ERROR,
+ g_io_channel_error_from_errno (errno),
+ g_strerror (errno));
+ return G_IO_STATUS_ERROR;
break;
default:
whence = -1; /* Keep the compiler quiet */
break;
default:
whence = -1; /* Keep the compiler quiet */
- g_assert_not_reached();
+ g_assert_not_reached ();
error = G_IO_CHANNEL_ERROR_FAILED;
break;
}
error = G_IO_CHANNEL_ERROR_FAILED;
break;
}
- g_set_error(err, G_IO_CHANNEL_ERROR, error, "Socket read error");
+ g_set_error (err, G_IO_CHANNEL_ERROR, error, "Socket read error");
internal_status = G_IO_STATUS_ERROR;
/* FIXME get all errors, better error messages */
}
internal_status = G_IO_STATUS_ERROR;
/* FIXME get all errors, better error messages */
}
{
*bytes_read = result;
if (result == 0)
{
*bytes_read = result;
if (result == 0)
- internal_status = G_IO_STATUS_EOF;
+ internal_status = G_IO_STATUS_EOF;
}
if ((internal_status == G_IO_STATUS_EOF) ||
}
if ((internal_status == G_IO_STATUS_EOF) ||
- (internal_status == G_IO_STATUS_ERROR))
- {
- LOCK (win32_channel->mutex);
- SetEvent(win32_channel->data_avail_noticed_event);
- win32_channel->needs_close = 1;
- send(win32_channel->reset_send, send_buffer, sizeof(send_buffer), 0);
- UNLOCK (win32_channel->mutex);
- }
+ (internal_status == G_IO_STATUS_ERROR))
+ {
+ LOCK (win32_channel->mutex);
+ SetEvent (win32_channel->data_avail_noticed_event);
+ win32_channel->needs_close = 1;
+ send (win32_channel->reset_send, send_buffer, sizeof (send_buffer), 0);
+ UNLOCK (win32_channel->mutex);
+ }
return internal_status;
}
return internal_status;
}
error = G_IO_CHANNEL_ERROR_FAILED;
break;
}
error = G_IO_CHANNEL_ERROR_FAILED;
break;
}
- g_set_error(err, G_IO_CHANNEL_ERROR, error, "Socket write error");
+ g_set_error (err, G_IO_CHANNEL_ERROR, error, "Socket write error");
LOCK (win32_channel->mutex);
LOCK (win32_channel->mutex);
- SetEvent(win32_channel->data_avail_noticed_event);
+ SetEvent (win32_channel->data_avail_noticed_event);
win32_channel->needs_close = 1;
win32_channel->needs_close = 1;
- send(win32_channel->reset_send, send_buffer, sizeof(send_buffer), 0);
+ send (win32_channel->reset_send, send_buffer, sizeof (send_buffer), 0);
UNLOCK (win32_channel->mutex);
UNLOCK (win32_channel->mutex);
- return G_IO_STATUS_ERROR;
+ return G_IO_STATUS_ERROR;
/* FIXME get all errors, better error messages */
}
else
/* FIXME get all errors, better error messages */
}
else
{
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
{
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
- LOCK(win32_channel->mutex);
+ LOCK (win32_channel->mutex);
if (win32_channel->running)
{
if (win32_channel->debug)
if (win32_channel->running)
{
if (win32_channel->debug)
closesocket (win32_channel->fd);
win32_channel->fd = -1;
}
closesocket (win32_channel->fd);
win32_channel->fd = -1;
}
- UNLOCK(win32_channel->mutex);
+ UNLOCK (win32_channel->mutex);
/* FIXME error detection? */
/* FIXME error detection? */
g_io_channel_init (channel);
g_io_channel_win32_init (win32_channel);
g_io_channel_init (channel);
g_io_channel_win32_init (win32_channel);
- init_reset_sockets(channel);
+ init_reset_sockets (win32_channel);
if (win32_channel->debug)
g_print ("g_io_channel_win32_new_socket: sockfd:%d\n", socket);
channel->funcs = &win32_channel_sock_funcs;
if (win32_channel->debug)
g_print ("g_io_channel_win32_new_socket: sockfd:%d\n", socket);
channel->funcs = &win32_channel_sock_funcs;
return g_io_channel_win32_new_fd_internal (fd, &st);
if (getsockopt (fd, SOL_SOCKET, SO_TYPE, NULL, NULL) != SOCKET_ERROR)
return g_io_channel_win32_new_fd_internal (fd, &st);
if (getsockopt (fd, SOL_SOCKET, SO_TYPE, NULL, NULL) != SOCKET_ERROR)
- return g_io_channel_win32_new_socket(fd);
+ return g_io_channel_win32_new_socket (fd);
g_warning (G_STRLOC ": %d is neither a file descriptor or a socket", fd);
return NULL;
g_warning (G_STRLOC ": %d is neither a file descriptor or a socket", fd);
return NULL;