]> git.neil.brown.name Git - gsm0710muxd.git/commitdiff
Be more careful about handing EOF read from the socket. master
authorNeil Brown <neilb@suse.de>
Sun, 8 Feb 2009 02:48:19 +0000 (13:48 +1100)
committerNeil Brown <neilb@suse.de>
Sun, 8 Feb 2009 02:48:19 +0000 (13:48 +1100)
There was a case were we would spin on EOF from the socket.

src/gsm0710muxd.c

index 70d41cf539314a41dcef579f1684a6c061bb4a96..ca67b12951fe0cf2adea76150d488580e489ec01 100644 (file)
@@ -607,7 +607,8 @@ gboolean pseudo_device_read(GIOChannel *source, GIOCondition condition, gpointer
                unsigned char buf[4096];
                //information from virtual port
                int len = read(channel->fd, buf + channel->remaining, sizeof(buf) - channel->remaining);
-               if (!channel->opened)
+
+               if (len > 0 && !channel->opened)
                {
                        LOG(LOG_WARNING, "Write to a channel which wasn't acked to be open.");
                        write_frame(channel->id, NULL, 0, GSM0710_TYPE_SABM | GSM0710_PF);