diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2012-04-27 15:32:39 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2012-04-27 15:32:39 +0200 |
commit | 980e2112cf7a987df40b3157a417ad0e3a831476 (patch) | |
tree | e447c8095073e225102360ccbfce8a42eda83f4d /libpipe/dgram.c | |
parent | 69bd9b1d600debf7b758cc7f8353b747430259b4 (diff) | |
download | hurd-980e2112cf7a987df40b3157a417ad0e3a831476.tar.gz hurd-980e2112cf7a987df40b3157a417ad0e3a831476.tar.bz2 hurd-980e2112cf7a987df40b3157a417ad0e3a831476.zip |
Add MSG_PEEK support to pflocal
* libpipe/pq.h (packet_peek): Declare new function.
* libpipe/pq.c (packet_read): Move code to new `packet_fetch' function, call it
with `remove' set to 1.
(packet_fetch): New function with code from `packet_read', but do not remove
data if `remove' is 0.
(packet_peek): New function, calls `packet_fetch' with `remove' set to 0.
* libpipe/dgram.c (dgram_read): When MSG_PEEK is in *flags, do not dequeue
and only peek data.
* libpipe/seqpack.c (seqpack_read): Likewise.
* libpipe/stream.c (stream_read): Likewise.
* pflocal/socket.c (S_socket_recv): Pass MSG_PEEK flag to libpipe.
Diffstat (limited to 'libpipe/dgram.c')
-rw-r--r-- | libpipe/dgram.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libpipe/dgram.c b/libpipe/dgram.c index 3f3b2ab6..30695f1e 100644 --- a/libpipe/dgram.c +++ b/libpipe/dgram.c @@ -40,8 +40,16 @@ static error_t dgram_read (struct packet *packet, int *dequeue, unsigned *flags, char **data, size_t *data_len, size_t amount) { - *dequeue = 1; - return packet_read (packet, data, data_len, amount); + if (flags && *flags & MSG_PEEK) + { + *dequeue = 0; + return packet_peek (packet, data, data_len, amount); + } + else + { + *dequeue = 1; + return packet_read (packet, data, data_len, amount); + } } struct pipe_class _dgram_pipe_class = |