diff options
| author | Ira Cooper <ira@samba.org> | 2015-01-22 17:14:31 -0500 |
|---|---|---|
| committer | Jeremy Allison <jra@samba.org> | 2015-01-23 20:58:51 +0100 |
| commit | 3b2d8bdbb1851961536241d3aaaf6ac936964517 (patch) | |
| tree | 4dc11fb9c84a43da337be846ff6b6d8ec5260b5d /source3/modules | |
| parent | fba69f4a89bedaf799b3a3c78cde43f4f1d1aba3 (diff) | |
| download | samba-3b2d8bdbb1851961536241d3aaaf6ac936964517.tar.gz samba-3b2d8bdbb1851961536241d3aaaf6ac936964517.tar.xz samba-3b2d8bdbb1851961536241d3aaaf6ac936964517.zip | |
vfs_glusterfs: Add comments to the pipe(2) code.
The guarantees around read(2) and write(2) and pipes are critical
to understanding this code. Hopefully these comments will help.
Signed-off-by: Ira Cooper <ira@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jan 23 20:58:51 CET 2015 on sn-devel-104
Diffstat (limited to 'source3/modules')
| -rw-r--r-- | source3/modules/vfs_glusterfs.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 04314f2b8b..e0cc85c0c8 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -521,6 +521,13 @@ static void aio_glusterfs_done(glfs_fd_t *fd, ssize_t ret, void *data) * be called here, as it is not designed to be executed * in the multithread environment, tevent_req_done() must be * executed from the smbd main thread. + * + * write(2) on pipes with sizes under _POSIX_PIPE_BUF + * in size is atomic, without this, the use op pipes in this + * code would not work. + * + * sys_write is a thin enough wrapper around write(2) + * that we can trust it here. */ sts = sys_write(write_fd, &req, sizeof(struct tevent_req *)); @@ -541,6 +548,16 @@ static void aio_tevent_fd_done(struct tevent_context *event_ctx, struct tevent_req *req = NULL; int sts = 0; + /* + * read(2) on pipes is atomic if the needed data is available + * in the pipe, per SUS and POSIX. Because we always write + * to the pipe in sizeof(struct tevent_req *) chunks, we can + * always read in those chunks, atomically. + * + * sys_read is a thin enough wrapper around read(2) that we + * can trust it here. + */ + sts = sys_read(read_fd, &req, sizeof(struct tevent_req *)); if (sts < 0) { DEBUG(0,("\nRead from pipe failed (%s)", strerror(errno))); |
