Commit f17ed7ee authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

Some indentation and spacing fixes. Add some more logging.

2000-08-12  Tor Lillqvist  <tml@iki.fi>

	* giowin32.c: Some indentation and spacing fixes. Add some more
	logging.
	(g_io_win32_add_watch): New function, with common code from
	g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
	more than one reader thread for a GIOChannel. We should obviously
	have just one reader thread reading a file descriptor or socket.
parent 4261dcfa
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
2000-08-12 Tor Lillqvist <tml@iki.fi>
* giowin32.c: Some indentation and spacing fixes. Add some more
logging.
(g_io_win32_add_watch): New function, with common code from
g_io_win32_fd_add_watch and g_io_win32_sock_add_watch. Don't start
more than one reader thread for a GIOChannel. We should obviously
have just one reader thread reading a file descriptor or socket.
2000-08-10 Havoc Pennington <hp@redhat.com> 2000-08-10 Havoc Pennington <hp@redhat.com>
* gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags * gthread-2.0.pc.in (Cflags): don't duplicate glib Cflags
......
...@@ -122,6 +122,8 @@ g_io_channel_win32_init (GIOWin32Channel *channel) ...@@ -122,6 +122,8 @@ g_io_channel_win32_init (GIOWin32Channel *channel)
channel->buffer = NULL; channel->buffer = NULL;
channel->running = FALSE; channel->running = FALSE;
channel->thread_id = 0; channel->thread_id = 0;
channel->data_avail_event = NULL;
channel->space_avail_event = NULL;
} }
static void static void
...@@ -133,9 +135,6 @@ create_events (GIOWin32Channel *channel) ...@@ -133,9 +135,6 @@ create_events (GIOWin32Channel *channel)
sec_attrs.lpSecurityDescriptor = NULL; sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = FALSE; sec_attrs.bInheritHandle = FALSE;
channel->data_avail_event = NULL;
channel->space_avail_event = NULL;
/* The data available event is manual reset, the space available event /* The data available event is manual reset, the space available event
* is automatic reset. * is automatic reset.
*/ */
...@@ -379,6 +378,43 @@ static GSourceFuncs win32_watch_funcs = { ...@@ -379,6 +378,43 @@ static GSourceFuncs win32_watch_funcs = {
g_io_win32_destroy g_io_win32_destroy
}; };
static guint
g_io_win32_add_watch (GIOChannel *channel,
gint priority,
GIOCondition condition,
GIOFunc func,
gpointer user_data,
GDestroyNotify notify,
int (*reader) (int, guchar *, int))
{
GIOWin32Watch *watch = g_new (GIOWin32Watch, 1);
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
watch->channel = channel;
g_io_channel_ref (channel);
watch->callback = func;
watch->condition = condition;
if (win32_channel->data_avail_event == NULL)
create_events (win32_channel);
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
watch->pollfd.events = condition;
if (win32_channel->debug)
g_print ("g_io_win32_add_watch: fd:%d handle:%#x\n",
win32_channel->fd, watch->pollfd.fd);
if (win32_channel->thread_id == 0)
create_reader_thread (win32_channel, reader);
g_main_add_poll (&watch->pollfd, priority);
return g_source_add (priority, TRUE, &win32_watch_funcs, watch,
user_data, notify);
}
static GIOError static GIOError
g_io_win32_msg_read (GIOChannel *channel, g_io_win32_msg_read (GIOChannel *channel,
gchar *buf, gchar *buf,
...@@ -428,7 +464,6 @@ g_io_win32_no_seek (GIOChannel *channel, ...@@ -428,7 +464,6 @@ g_io_win32_no_seek (GIOChannel *channel,
return G_IO_ERROR_UNKNOWN; return G_IO_ERROR_UNKNOWN;
} }
static void static void
g_io_win32_msg_close (GIOChannel *channel) g_io_win32_msg_close (GIOChannel *channel)
{ {
...@@ -478,14 +513,18 @@ g_io_win32_msg_add_watch (GIOChannel *channel, ...@@ -478,14 +513,18 @@ g_io_win32_msg_add_watch (GIOChannel *channel,
static GIOError static GIOError
g_io_win32_fd_read (GIOChannel *channel, g_io_win32_fd_read (GIOChannel *channel,
gchar *buf, gchar *buf,
guint count, guint count,
guint *bytes_read) guint *bytes_read)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
gint result; gint result;
GIOError error; GIOError error;
if (win32_channel->debug)
g_print ("g_io_win32_fd_read: fd:%d count:%d\n",
win32_channel->fd, count);
if (win32_channel->thread_id) if (win32_channel->thread_id)
{ {
result = buffer_read (win32_channel, buf, count, &error); result = buffer_read (win32_channel, buf, count, &error);
...@@ -519,10 +558,10 @@ g_io_win32_fd_read (GIOChannel *channel, ...@@ -519,10 +558,10 @@ g_io_win32_fd_read (GIOChannel *channel,
} }
static GIOError static GIOError
g_io_win32_fd_write(GIOChannel *channel, g_io_win32_fd_write (GIOChannel *channel,
gchar *buf, gchar *buf,
guint count, guint count,
guint *bytes_written) guint *bytes_written)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
gint result; gint result;
...@@ -554,8 +593,8 @@ g_io_win32_fd_write(GIOChannel *channel, ...@@ -554,8 +593,8 @@ g_io_win32_fd_write(GIOChannel *channel,
static GIOError static GIOError
g_io_win32_fd_seek (GIOChannel *channel, g_io_win32_fd_seek (GIOChannel *channel,
gint offset, gint offset,
GSeekType type) GSeekType type)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
int whence; int whence;
...@@ -618,30 +657,8 @@ g_io_win32_fd_add_watch (GIOChannel *channel, ...@@ -618,30 +657,8 @@ g_io_win32_fd_add_watch (GIOChannel *channel,
gpointer user_data, gpointer user_data,
GDestroyNotify notify) GDestroyNotify notify)
{ {
GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); return g_io_win32_add_watch (channel, priority, condition,
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; func, user_data, notify, fd_reader);
watch->channel = channel;
g_io_channel_ref (channel);
watch->callback = func;
watch->condition = condition;
create_events (win32_channel);
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
watch->pollfd.events = condition;
if (win32_channel->debug)
g_print ("g_io_win32_fd_add_watch: fd:%d handle:%#x\n",
win32_channel->fd, watch->pollfd.fd);
create_reader_thread (win32_channel, fd_reader);
g_main_add_poll (&watch->pollfd, priority);
return g_source_add (priority, TRUE, &win32_watch_funcs,
watch, user_data, notify);
} }
static GIOError static GIOError
...@@ -684,10 +701,10 @@ g_io_win32_sock_read (GIOChannel *channel, ...@@ -684,10 +701,10 @@ g_io_win32_sock_read (GIOChannel *channel,
} }
static GIOError static GIOError
g_io_win32_sock_write(GIOChannel *channel, g_io_win32_sock_write (GIOChannel *channel,
gchar *buf, gchar *buf,
guint count, guint count,
guint *bytes_written) guint *bytes_written)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
gint result; gint result;
...@@ -739,27 +756,8 @@ g_io_win32_sock_add_watch (GIOChannel *channel, ...@@ -739,27 +756,8 @@ g_io_win32_sock_add_watch (GIOChannel *channel,
gpointer user_data, gpointer user_data,
GDestroyNotify notify) GDestroyNotify notify)
{ {
GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); return g_io_win32_add_watch (channel, priority, condition,
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; func, user_data, notify, sock_reader);
watch->channel = channel;
g_io_channel_ref (channel);
watch->callback = func;
watch->condition = condition;
create_events (win32_channel);
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
watch->pollfd.events = condition;
/* Sockets are always readable, aren't they? */
create_reader_thread (win32_channel, sock_reader);
g_main_add_poll (&watch->pollfd, priority);
return g_source_add (priority, TRUE, &win32_watch_funcs, watch,
user_data, notify);
} }
static GIOFuncs win32_channel_msg_funcs = { static GIOFuncs win32_channel_msg_funcs = {
...@@ -915,23 +913,23 @@ g_io_channel_win32_new_pipe (int fd) ...@@ -915,23 +913,23 @@ g_io_channel_win32_new_pipe (int fd)
GIOChannel * GIOChannel *
g_io_channel_win32_new_pipe_with_wakeups (int fd, g_io_channel_win32_new_pipe_with_wakeups (int fd,
guint peer, guint peer,
int peer_fd) int peer_fd)
{ {
return g_io_channel_win32_new_fd (fd); return g_io_channel_win32_new_fd (fd);
} }
void void
g_io_channel_win32_pipe_request_wakeups (GIOChannel *channel, g_io_channel_win32_pipe_request_wakeups (GIOChannel *channel,
guint peer, guint peer,
int peer_fd) int peer_fd)
{ {
/* Nothing needed now */ /* Nothing needed now */
} }
void void
g_io_channel_win32_pipe_readable (gint fd, g_io_channel_win32_pipe_readable (gint fd,
guint offset) guint offset)
{ {
/* Nothing needed now */ /* Nothing needed now */
} }
......
...@@ -122,6 +122,8 @@ g_io_channel_win32_init (GIOWin32Channel *channel) ...@@ -122,6 +122,8 @@ g_io_channel_win32_init (GIOWin32Channel *channel)
channel->buffer = NULL; channel->buffer = NULL;
channel->running = FALSE; channel->running = FALSE;
channel->thread_id = 0; channel->thread_id = 0;
channel->data_avail_event = NULL;
channel->space_avail_event = NULL;
} }
static void static void
...@@ -133,9 +135,6 @@ create_events (GIOWin32Channel *channel) ...@@ -133,9 +135,6 @@ create_events (GIOWin32Channel *channel)
sec_attrs.lpSecurityDescriptor = NULL; sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = FALSE; sec_attrs.bInheritHandle = FALSE;
channel->data_avail_event = NULL;
channel->space_avail_event = NULL;
/* The data available event is manual reset, the space available event /* The data available event is manual reset, the space available event
* is automatic reset. * is automatic reset.
*/ */
...@@ -379,6 +378,43 @@ static GSourceFuncs win32_watch_funcs = { ...@@ -379,6 +378,43 @@ static GSourceFuncs win32_watch_funcs = {
g_io_win32_destroy g_io_win32_destroy
}; };
static guint
g_io_win32_add_watch (GIOChannel *channel,
gint priority,
GIOCondition condition,
GIOFunc func,
gpointer user_data,
GDestroyNotify notify,
int (*reader) (int, guchar *, int))
{
GIOWin32Watch *watch = g_new (GIOWin32Watch, 1);
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
watch->channel = channel;
g_io_channel_ref (channel);
watch->callback = func;
watch->condition = condition;
if (win32_channel->data_avail_event == NULL)
create_events (win32_channel);
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
watch->pollfd.events = condition;
if (win32_channel->debug)
g_print ("g_io_win32_add_watch: fd:%d handle:%#x\n",
win32_channel->fd, watch->pollfd.fd);
if (win32_channel->thread_id == 0)
create_reader_thread (win32_channel, reader);
g_main_add_poll (&watch->pollfd, priority);
return g_source_add (priority, TRUE, &win32_watch_funcs, watch,
user_data, notify);
}
static GIOError static GIOError
g_io_win32_msg_read (GIOChannel *channel, g_io_win32_msg_read (GIOChannel *channel,
gchar *buf, gchar *buf,
...@@ -428,7 +464,6 @@ g_io_win32_no_seek (GIOChannel *channel, ...@@ -428,7 +464,6 @@ g_io_win32_no_seek (GIOChannel *channel,
return G_IO_ERROR_UNKNOWN; return G_IO_ERROR_UNKNOWN;
} }
static void static void
g_io_win32_msg_close (GIOChannel *channel) g_io_win32_msg_close (GIOChannel *channel)
{ {
...@@ -478,14 +513,18 @@ g_io_win32_msg_add_watch (GIOChannel *channel, ...@@ -478,14 +513,18 @@ g_io_win32_msg_add_watch (GIOChannel *channel,
static GIOError static GIOError
g_io_win32_fd_read (GIOChannel *channel, g_io_win32_fd_read (GIOChannel *channel,
gchar *buf, gchar *buf,
guint count, guint count,
guint *bytes_read) guint *bytes_read)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
gint result; gint result;
GIOError error; GIOError error;
if (win32_channel->debug)
g_print ("g_io_win32_fd_read: fd:%d count:%d\n",
win32_channel->fd, count);
if (win32_channel->thread_id) if (win32_channel->thread_id)
{ {
result = buffer_read (win32_channel, buf, count, &error); result = buffer_read (win32_channel, buf, count, &error);
...@@ -519,10 +558,10 @@ g_io_win32_fd_read (GIOChannel *channel, ...@@ -519,10 +558,10 @@ g_io_win32_fd_read (GIOChannel *channel,
} }
static GIOError static GIOError
g_io_win32_fd_write(GIOChannel *channel, g_io_win32_fd_write (GIOChannel *channel,
gchar *buf, gchar *buf,
guint count, guint count,
guint *bytes_written) guint *bytes_written)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
gint result; gint result;
...@@ -554,8 +593,8 @@ g_io_win32_fd_write(GIOChannel *channel, ...@@ -554,8 +593,8 @@ g_io_win32_fd_write(GIOChannel *channel,
static GIOError static GIOError
g_io_win32_fd_seek (GIOChannel *channel, g_io_win32_fd_seek (GIOChannel *channel,
gint offset, gint offset,
GSeekType type) GSeekType type)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
int whence; int whence;
...@@ -618,30 +657,8 @@ g_io_win32_fd_add_watch (GIOChannel *channel, ...@@ -618,30 +657,8 @@ g_io_win32_fd_add_watch (GIOChannel *channel,
gpointer user_data, gpointer user_data,
GDestroyNotify notify) GDestroyNotify notify)
{ {
GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); return g_io_win32_add_watch (channel, priority, condition,
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; func, user_data, notify, fd_reader);
watch->channel = channel;
g_io_channel_ref (channel);
watch->callback = func;
watch->condition = condition;
create_events (win32_channel);
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
watch->pollfd.events = condition;
if (win32_channel->debug)
g_print ("g_io_win32_fd_add_watch: fd:%d handle:%#x\n",
win32_channel->fd, watch->pollfd.fd);
create_reader_thread (win32_channel, fd_reader);
g_main_add_poll (&watch->pollfd, priority);
return g_source_add (priority, TRUE, &win32_watch_funcs,
watch, user_data, notify);
} }
static GIOError static GIOError
...@@ -684,10 +701,10 @@ g_io_win32_sock_read (GIOChannel *channel, ...@@ -684,10 +701,10 @@ g_io_win32_sock_read (GIOChannel *channel,
} }
static GIOError static GIOError
g_io_win32_sock_write(GIOChannel *channel, g_io_win32_sock_write (GIOChannel *channel,
gchar *buf, gchar *buf,
guint count, guint count,
guint *bytes_written) guint *bytes_written)
{ {
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
gint result; gint result;
...@@ -739,27 +756,8 @@ g_io_win32_sock_add_watch (GIOChannel *channel, ...@@ -739,27 +756,8 @@ g_io_win32_sock_add_watch (GIOChannel *channel,
gpointer user_data, gpointer user_data,
GDestroyNotify notify) GDestroyNotify notify)
{ {
GIOWin32Watch *watch = g_new (GIOWin32Watch, 1); return g_io_win32_add_watch (channel, priority, condition,
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; func, user_data, notify, sock_reader);
watch->channel = channel;
g_io_channel_ref (channel);
watch->callback = func;
watch->condition = condition;
create_events (win32_channel);
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
watch->pollfd.events = condition;
/* Sockets are always readable, aren't they? */
create_reader_thread (win32_channel, sock_reader);
g_main_add_poll (&watch->pollfd, priority);
return g_source_add (priority, TRUE, &win32_watch_funcs, watch,
user_data, notify);
} }
static GIOFuncs win32_channel_msg_funcs = { static GIOFuncs win32_channel_msg_funcs = {
...@@ -915,23 +913,23 @@ g_io_channel_win32_new_pipe (int fd) ...@@ -915,23 +913,23 @@ g_io_channel_win32_new_pipe (int fd)
GIOChannel * GIOChannel *
g_io_channel_win32_new_pipe_with_wakeups (int fd, g_io_channel_win32_new_pipe_with_wakeups (int fd,
guint peer, guint peer,
int peer_fd) int peer_fd)
{ {
return g_io_channel_win32_new_fd (fd); return g_io_channel_win32_new_fd (fd);
} }
void void
g_io_channel_win32_pipe_request_wakeups (GIOChannel *channel, g_io_channel_win32_pipe_request_wakeups (GIOChannel *channel,
guint peer, guint peer,
int peer_fd) int peer_fd)
{ {
/* Nothing needed now */ /* Nothing needed now */
} }
void void
g_io_channel_win32_pipe_readable (gint fd, g_io_channel_win32_pipe_readable (gint fd,
guint offset) guint offset)
{ {
/* Nothing needed now */ /* Nothing needed now */
} }
......
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