Commit 53be85e1 authored by Eric Wong's avatar Eric Wong

notify: more cleanups, add error checking for pipe errors

Don't bother initializing the junk buffer, we really don't care. The array was also unnecessary and ugly. Also, avoid returning the byte count we read/wrote since it unnecessarily exposes internal details of the implementation to the callers. git-svn-id: https://svn.musicpd.org/mpd/trunk@7219 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 19d4f6df
...@@ -30,18 +30,19 @@ void initNotify(Notify *notify) ...@@ -30,18 +30,19 @@ void initNotify(Notify *notify)
strerror(errno)); strerror(errno));
} }
int waitNotify(Notify *notify) void waitNotify(Notify *notify)
{ {
char buffer[64]; char buffer[64];
ssize_t nbytes;
nbytes = read(notify->fds[0], buffer, sizeof(buffer)); if (read(notify->fds[0], buffer, sizeof(buffer)) < 0)
return (int)nbytes; FATAL("error reading from pipe: %s\n", strerror(errno));
} }
int signalNotify(Notify *notify) void signalNotify(Notify *notify)
{ {
char buffer[1] = { 0 }; char buffer;
return (int)write(notify->fds[1], &buffer, sizeof(buffer)); if (write(notify->fds[1], &buffer, sizeof(buffer)) < 0 &&
errno != EAGAIN && errno != EINTR)
FATAL("error writing to pipe: %s\n", strerror(errno));
} }
...@@ -40,8 +40,8 @@ typedef struct _Notify { ...@@ -40,8 +40,8 @@ typedef struct _Notify {
void initNotify(Notify *notify); void initNotify(Notify *notify);
int waitNotify(Notify *notify); void waitNotify(Notify *notify);
int signalNotify(Notify *notify); void signalNotify(Notify *notify);
#endif #endif
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