]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/afs_argv0'
authorAndre Noll <maan@systemlinux.org>
Sat, 29 Oct 2011 09:08:26 +0000 (11:08 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 29 Oct 2011 09:08:26 +0000 (11:08 +0200)
17 files changed:
NEWS
aac_afh.c
afs.c
aft.c
command.c
crypt.c
dccp_recv.c
imdct.c
ipc.c
net.c
net.h
ogg_afh.c
oggdec_filter.c
sched.c
vss.c
wma_common.c
wmadec_filter.c

diff --git a/NEWS b/NEWS
index 6db7225350f014f80e3f0ad831fe60b93d2777b9..3a7027298f5a20ee00793554b2be89a997f331c3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@
        - Shared memory areas are no longer restricted to 64K. We now
          detect the maximal size of a shared memory area at runtime.
        - cleanup of the internal uptime API.
+       - para_server prefaults the mmapped audio file to avoid
+         delays on slow media.
 
 --------------------------------------
 0.4.8 (2011-08-19) "nested assignment"
index a53a757fd89777720cf5dafca5589ccad3117216..7acb011df165a09a9536a850e7b736dbfa7b9eec 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -191,8 +191,7 @@ static int aac_set_chunk_tv(struct afh_info *afhi,
 {
        float tmp = mp4ASC->sbr_present_flag == 1? 2047 : 1023;
        struct timeval total;
-       long unsigned ms = 1000.0 * afhi->chunks_total * tmp
-               / mp4ASC->samplingFrequency;
+       long unsigned ms;
 
        if (!mp4ASC->samplingFrequency)
                return -E_MP4ASC;
diff --git a/afs.c b/afs.c
index 955b8f207d5305418674f6a0f2e30f904d110517..3f3780519ab0ddddcba6ff876ead15324b9951ec 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -286,6 +286,9 @@ out:
  * command. This function allows to pass such a structure together with a list
  * of further arguments (often a list of audio files) to the parent process.
  *
+ * \return The return value of the underlying call to \ref
+ * send_callback_request().
+ *
  * \sa send_standard_callback_request(), send_callback_request().
  */
 int send_option_arg_callback_request(struct osl_object *options,
@@ -1146,7 +1149,8 @@ void afs_event(enum afs_events event, struct para_buffer *pb,
  * \param pb Unused.
  * \param data Unused.
  *
- * This table does not honor events.
+ * \return The images table does not honor events, so this handler always
+ * returns success.
  */
 __a_const int images_event_handler(__a_unused enum afs_events event,
        __a_unused  struct para_buffer *pb, __a_unused void *data)
@@ -1161,7 +1165,8 @@ __a_const int images_event_handler(__a_unused enum afs_events event,
  * \param pb Unused.
  * \param data Unused.
  *
- * This table does not honor events.
+ * \return The lyrics table does not honor events, so this handler always
+ * returns success.
  */
 __a_const int lyrics_event_handler(__a_unused enum afs_events event,
        __a_unused struct para_buffer *pb, __a_unused void *data)
diff --git a/aft.c b/aft.c
index e91d734fea7d70e74350cdcfdc3c4def9bce8a05..3d22e242ef94ab21b17487b345d636a01dabb3d9 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -2481,6 +2481,8 @@ static void afs_stat_callback(int fd, const struct osl_object *query)
  * up-to-date afs status items directly. Therefore the usual callback mechanism
  * is used to pass the status items from the afs process to the command handler
  * via a shared memory area and a pipe.
+ *
+ * \return The return value of the underyling call to \ref send_callback_request().
  */
 int send_afs_status(struct stream_cipher_context *scc, int parser_friendly)
 {
index 3ba4310511c7683c66e7fb5a0f68af28e3ef14b0..b6861b88bbcb36621109f6d9ac7fe80546a42b35 100644 (file)
--- a/command.c
+++ b/command.c
@@ -763,13 +763,11 @@ __noreturn void handle_connect(int fd, const char *peername)
                ret = -E_AUTH_REQUEST;
                goto net_err;
        }
-       numbytes = ret;
        ret = -E_AUTH_REQUEST;
        if (strncmp(buf, AUTH_REQUEST_MSG, strlen(AUTH_REQUEST_MSG)))
                goto net_err;
        p = buf + strlen(AUTH_REQUEST_MSG);
        PARA_DEBUG_LOG("received auth request for user %s\n", p);
-       ret = -E_BAD_USER;
        u = lookup_user(p);
        if (u) {
                get_random_bytes_or_die(rand_buf, sizeof(rand_buf));
diff --git a/crypt.c b/crypt.c
index 7b7c16d348952dab0dccbbd2170af178a703adb3..431de6fe807f5a08acb8d4e62e0e6e3c160b6e1c 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -184,24 +184,25 @@ int get_asymmetric_key(const char *key_file, int private,
        PARA_INFO_LOG("decoding public rsa-ssh key %s\n", key_file);
        ret = -ERRNO_TO_PARA_ERROR(EOVERFLOW);
        if (map_size > INT_MAX / 4)
-               goto out;
+               goto out_unmap;
        blob_size = 2 * map_size;
        blob = para_malloc(blob_size);
        ret = uudecode(cp, blob, blob_size);
        if (ret < 0)
-               goto out;
+               goto out_unmap;
        decoded_size = ret;
        ret = check_ssh_key_header(blob, decoded_size);
        if (ret < 0)
-               goto out;
+               goto out_unmap;
        ret = read_rsa_bignums(blob + ret, decoded_size - ret, &key->rsa);
        if (ret < 0)
-               goto out;
+               goto out_unmap;
        ret = RSA_size(key->rsa);
-out:
+out_unmap:
        ret2 = para_munmap(map, map_size);
        if (ret >= 0 && ret2 < 0)
                ret = ret2;
+out:
        if (ret < 0) {
                free(key);
                *result = NULL;
index af8e6b1657e86777af5f6360c573c60bcc46e93c..a9eab006bd3cf0f0d4ddc6e5ac41ba6beb30199a 100644 (file)
@@ -40,13 +40,14 @@ struct private_dccp_recv_data {
 
 static void dccp_recv_close(struct receiver_node *rn)
 {
-
        struct private_dccp_recv_data *pdd = rn->private_data;
 
-       if (pdd && pdd->fd > 0)
+       if (!pdd)
+               return;
+       if (pdd->fd > 0)
                close(pdd->fd);
        btr_pool_free(pdd->btrp);
-       free(rn->private_data);
+       free(pdd);
        rn->private_data = NULL;
 }
 
diff --git a/imdct.c b/imdct.c
index 32928487b724653535d604adbf690e013a7eb516..aab498a390ba3ecdeded2452120d729540e84184 100644 (file)
--- a/imdct.c
+++ b/imdct.c
@@ -293,7 +293,6 @@ static void imdct_half(struct mdct_context *s, fftsample_t *output,
        fft(&s->fft, z);
 
        /* post rotation + reordering */
-       output += n4;
        for (k = 0; k < n8; k++) {
                fftsample_t r0, i0, r1, i1;
                CMUL(r0, i1, z[n8 - k - 1].im, z[n8 - k - 1].re,
diff --git a/ipc.c b/ipc.c
index 674d1cb01e5fae9c5ae2ecb8f8ceec92fa9faa62..576bfe5bcd815ee296da0b56d49a7f3ea5d97e4e 100644 (file)
--- a/ipc.c
+++ b/ipc.c
@@ -184,6 +184,15 @@ int shm_detach(void *addr)
 #      undef SYSCTL_SHMMAX_VARIABLE
 # endif
 
+/**
+ * Get the maximal size of a shared memory area.
+ *
+ * The value is only computed once when the function is called for the first
+ * time.  Subsequent calls return the number which was computed during the
+ * first call.
+ *
+ * \return A number suitable as an argument to \ref shm_new().
+ */
 size_t shm_get_shmmax(void)
 {
        static size_t shmmax;
diff --git a/net.c b/net.c
index 9b58e22539e8277c674425f689d1f3c261c2d48a..49026db0ec91a7b4a1d3d0917723720eb8d0ba30 100644 (file)
--- a/net.c
+++ b/net.c
@@ -578,10 +578,12 @@ static inline int estimated_header_overhead(const int af_type)
 /**
  * Get the maximum transport-layer message size (MMS_S).
  *
- * The socket must be connected. See RFC 1122, 3.3.3.
+ * \param sockfd The socket file descriptor.
  *
- * \return If the protocol familiy could not be determined, \p AF_INET is
- * assumed.
+ * The socket must be connected. See RFC 1122, 3.3.3. If the protocol familiy
+ * could not be determined, \p AF_INET is assumed.
+ *
+ * \return The maximum message size of the address family type.
  */
 int generic_max_transport_msg_size(int sockfd)
 {
diff --git a/net.h b/net.h
index 80f5794466fe74b8dbb429ad2ae2d38415945dba..79c5994c43ec2b0b6ae8fee1933b492c9f97a20d 100644 (file)
--- a/net.h
+++ b/net.h
@@ -8,13 +8,15 @@
 /** \file net.h exported symbols from net.c */
 
 /**
- * the buffer size of the sun_path component of struct sockaddr_un
+ * The buffer size of the sun_path component of struct sockaddr_un.
  *
- * While glibc doesn't define \p UNIX_PATH_MAX, it
- * documents it has being limited to 108 bytes.
+ * While glibc doesn't define \p UNIX_PATH_MAX, it documents it has being
+ * limited to 108 bytes. On NetBSD it is only 104 bytes though. We trust \p
+ * UNIX_PATH_MAX if it is defined and use the size of the ->sun_path member
+ * otherwise. This should be safe everywhere.
  */
 #ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
+#define UNIX_PATH_MAX (sizeof(((struct sockaddr_un *)0)->sun_path))
 #endif
 
 /* Userland defines for Linux DCCP support. */
index 46c7b084c0ba7b8aaf22683ba5897f94532f9db2..08023458216cff6065c9d02e248c505da6524773 100644 (file)
--- a/ogg_afh.c
+++ b/ogg_afh.c
@@ -105,7 +105,6 @@ static int vorbis_get_header_callback(ogg_packet *packet, int packet_num,
                return 0;
        if (packet_num == 0) {
                ogg_stream_init(&vghd->os, serial);
-               ret = -E_OGG_PACKET_IN;
                ret = ogg_stream_packetin(&vghd->os, packet);
                if (ret < 0)
                        goto out;
index 32ffdef97462a9bf3a3509a25b865f69ed8fe8c5..07e4cec1c1d6ac99fcc482beedf77914d1d157b7 100644 (file)
@@ -175,6 +175,7 @@ out:
                pod->converted = 0;
                fn->min_iqs = 0;
                pod->vf = vf;
+               pod->have_more = true;
        }
        return ret;
 }
diff --git a/sched.c b/sched.c
index 06aabe02b9934e5107ea97f1a8769af060184da7..66a17418027a5e9fa2d92bee412cf682561115b9 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -335,8 +335,8 @@ int sched_request_barrier(struct timeval *barrier, struct sched *s)
  * \param barrier Absolute time before select() should return.
  * \param s Pointer to the scheduler struct.
  *
- * If \a barrier is in the past, this function requests a minimal timeout and
- * returns zero. Otherwise it returns one.
+ * \return If \a barrier is in the past, this function requests a minimal
+ * timeout and returns zero. Otherwise it returns one.
  *
  * \sa sched_min_delay(), sched_request_barrier().
  */
diff --git a/vss.c b/vss.c
index b9afc8ed637374c82918f3448695a1a2fdaa94a2..e336a9e7413d469c71a6221cab0e86b0aae24867 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -132,6 +132,7 @@ struct fec_group {
        uint16_t slice_bytes;
 };
 
+/** A FEC client is always in one of these states. */
 enum fec_client_state {
        FEC_STATE_NONE = 0,     /**< not initialized and not enabled */
        FEC_STATE_DISABLED,     /**< temporarily disabled */
@@ -952,6 +953,10 @@ static int recv_afs_msg(int afs_socket, int *fd, uint32_t *code, uint32_t *data)
        return 1;
 }
 
+#ifndef MAP_POPULATE
+#define MAP_POPULATE 0
+#endif
+
 static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
 {
        int ret, passed_fd, shmid;
@@ -986,8 +991,8 @@ static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
        }
        mmd->size = statbuf.st_size;
        mmd->mtime = statbuf.st_mtime;
-       ret = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE, passed_fd,
-               0, &vsst->map);
+       ret = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
+               passed_fd, 0, &vsst->map);
        if (ret < 0)
                goto err;
        close(passed_fd);
@@ -1076,6 +1081,23 @@ static void vss_send(struct vss_task *vsst)
                }
                mmd->chunks_sent++;
                mmd->current_chunk++;
+               /*
+                * Prefault next chunk(s)
+                *
+                * If the backing device of the memory-mapped audio file is
+                * slow and read-ahead is turned off or prevented for some
+                * reason, e.g. due to memory pressure, it may take much longer
+                * than the chunk interval to get the next chunk on the wire,
+                * causing buffer underruns on the client side. Mapping the
+                * file with MAP_POPULATE seems to help a bit, but it does not
+                * eliminate the delays completely. Moreover, it is supported
+                * only on Linux. So we do our own read-ahead here.
+                */
+               buf += len;
+               for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
+                       __a_unused volatile char x = *buf;
+                       buf += 4096;
+               }
        }
 }
 
index 1dde83509f2e38e8ba044fc961c381e06b74b7ca..519be89cfa2f1c3a74b7f90fea4e2045d2f6a6a7 100644 (file)
@@ -28,6 +28,8 @@
  * \param pattern_len The length of the pattern in bytes.
  * \param buf The buffer to search for the pattern.
  * \param buf_size The number of bytes in \a buf.
+ *
+ * \return A pointer into \a buf or \p NULL if the pattern was not found.
  */
 const char *search_pattern(const char *pattern, int pattern_len,
                const char *buf, int buf_size)
index 0b381c5d9f0baabb657d0b8d51adfb8683e1495b..c6eb0b1cad291bce42f3eda474a9a9c62a28c8b3 100644 (file)
@@ -769,7 +769,6 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd,
                                *coefs++ = 0.0;
                        continue;
                }
-               mult1 = mult;
                n1 = pwd->exponent_high_sizes[bsize];
                /* compute power of high bands */
                exponents = pwd->exponents[ch] +
@@ -803,8 +802,7 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd,
                                mult1 = sqrt(exp_power[j]
                                        / exp_power[last_high_band]);
                                /* XXX: use a table */
-                               mult1 = mult1 * pow(10,
-                                       pwd->high_band_values[ch][j] * 0.05);
+                               mult1 *= pow(10, pwd->high_band_values[ch][j] * 0.05);
                                mult1 /= (pwd->max_exponent[ch] * pwd->noise_mult);
                                mult1 *= mdct_norm;
                                for (i = 0; i < n; i++) {
@@ -1012,7 +1010,6 @@ next:
        for (ch = 0; ch < pwd->ahi.channels; ch++) {
                int n4, idx;
 
-               n = pwd->block_len;
                n4 = pwd->block_len / 2;
                if (pwd->channel_coded[ch])
                        imdct(pwd->mdct_ctx[bsize], pwd->output, pwd->coefs[ch]);