]> code.delx.au - pulseaudio/commitdiff
Use pa_read, pa_write and pa_poll instead of system functions
authorMaarten Bosmans <mkbosmans@gmail.com>
Wed, 5 Jan 2011 18:50:44 +0000 (19:50 +0100)
committerMaarten Bosmans <mkbosmans@gmail.com>
Thu, 17 Feb 2011 11:02:31 +0000 (12:02 +0100)
src/daemon/cpulimit.c
src/pulse/thread-mainloop.c
src/pulsecore/fdsem.c
src/pulsecore/lock-autospawn.c

index f5042a754ded24ac4237d8196354bf3e96bde0e4..c1c2a6f63d471c1c95b78e4fc2e51d337e9964da 100644 (file)
@@ -140,7 +140,7 @@ static void signal_handler(int sig) {
             write_err("Soft CPU time limit exhausted, terminating.\n");
 
             /* Try a soft cleanup */
-            (void) write(the_pipe[1], &c, sizeof(c));
+            (void) pa_write(the_pipe[1], &c, sizeof(c), NULL);
             phase = PHASE_SOFT;
             reset_cpu_time(CPUTIME_INTERVAL_HARD);
 
index d8c82c8cd12b00c6deeefec1eb27ebe17e466710..ef4ef56ef467bc9d3c7758636f3e756b42ef63b5 100644 (file)
@@ -67,7 +67,7 @@ static int poll_func(struct pollfd *ufds, unsigned long nfds, int timeout, void
      * avahi_simple_poll_quit() can succeed from another thread. */
 
     pa_mutex_unlock(mutex);
-    r = poll(ufds, nfds, timeout);
+    r = pa_poll(ufds, nfds, timeout);
     pa_mutex_lock(mutex);
 
     return r;
index 5bf994793c78b04808505d1a5e9e5cf40192c1e8..6238045106b32eb46f7489e5e9ac5e5347c06084 100644 (file)
@@ -154,7 +154,7 @@ static void flush(pa_fdsem *f) {
         if (f->efd >= 0) {
             uint64_t u;
 
-            if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
+            if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
 
                 if (r >= 0 || errno != EINTR) {
                     pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
@@ -167,7 +167,7 @@ static void flush(pa_fdsem *f) {
         } else
 #endif
 
-        if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
+        if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
 
             if (r >= 0 || errno != EINTR) {
                 pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
@@ -197,9 +197,9 @@ void pa_fdsem_post(pa_fdsem *f) {
                 if (f->efd >= 0) {
                     uint64_t u = 1;
 
-                    if ((r = write(f->efd, &u, sizeof(u))) != sizeof(u)) {
+                    if ((r = pa_write(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
                         if (r >= 0 || errno != EINTR) {
-                            pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
+                            pa_log_error("Invalid write to eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
                             pa_assert_not_reached();
                         }
 
@@ -208,9 +208,9 @@ void pa_fdsem_post(pa_fdsem *f) {
                 } else
 #endif
 
-                if ((r = write(f->fds[1], &x, 1)) != 1) {
+                if ((r = pa_write(f->fds[1], &x, 1, NULL)) != 1) {
                     if (r >= 0 || errno != EINTR) {
-                        pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
+                        pa_log_error("Invalid write to pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
                         pa_assert_not_reached();
                     }
 
@@ -241,10 +241,10 @@ void pa_fdsem_wait(pa_fdsem *f) {
         if (f->efd >= 0) {
             uint64_t u;
 
-            if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
+            if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
 
                 if (r >= 0 || errno != EINTR) {
-                    pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
+                    pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
                     pa_assert_not_reached();
                 }
 
@@ -255,7 +255,7 @@ void pa_fdsem_wait(pa_fdsem *f) {
         } else
 #endif
 
-        if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
+        if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
 
             if (r >= 0 || errno != EINTR) {
                 pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
index 1a082db66aea78ab693c12796a4502a83084f062..a9c942fbb222cefb6266a7325ea4aaa490d2096f 100644 (file)
@@ -161,7 +161,7 @@ static void ping(void) {
     for (;;) {
         char x = 'x';
 
-        if ((s = write(pipe_fd[1], &x, 1)) == 1)
+        if ((s = pa_write(pipe_fd[1], &x, 1, NULL)) == 1)
             break;
 
         pa_assert(s < 0);
@@ -188,7 +188,7 @@ static void wait_for_ping(void) {
     if ((k = pa_poll(&pfd, 1, -1)) != 1) {
         pa_assert(k < 0);
         pa_assert(errno == EINTR);
-    } else if ((s = read(pipe_fd[0], &x, 1)) != 1) {
+    } else if ((s = pa_read(pipe_fd[0], &x, 1, NULL)) != 1) {
         pa_assert(s < 0);
         pa_assert(errno == EAGAIN);
     }
@@ -200,7 +200,7 @@ static void empty_pipe(void) {
 
     pa_assert(pipe_fd[0] >= 0);
 
-    if ((s = read(pipe_fd[0], &x, sizeof(x))) < 1) {
+    if ((s = pa_read(pipe_fd[0], &x, sizeof(x), NULL)) < 1) {
         pa_assert(s < 0);
         pa_assert(errno == EAGAIN);
     }