1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-25 06:04:04 +03:00

s3-libasys: Add asys_fsync() implementation

Signed-off-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2012-07-13 09:37:40 +02:00 committed by Jeremy Allison
parent fd351b6ebb
commit dc5e3fba48

View File

@ -35,9 +35,14 @@ struct asys_pread_args {
off_t offset;
};
struct asys_fsync_args {
int fildes;
};
union asys_job_args {
struct asys_pwrite_args pwrite_args;
struct asys_pread_args pread_args;
struct asys_fsync_args fsync_args;
};
struct asys_job {
@ -232,6 +237,44 @@ static void asys_pread_do(void *private_data)
}
}
static void asys_fsync_do(void *private_data);
int asys_fsync(struct asys_context *ctx, int fildes, void *private_data)
{
struct asys_job *job;
struct asys_fsync_args *args;
int jobid;
int ret;
ret = asys_new_job(ctx, &jobid, &job);
if (ret != 0) {
return ret;
}
job->private_data = private_data;
args = &job->args.fsync_args;
args->fildes = fildes;
ret = pthreadpool_add_job(ctx->pool, jobid, asys_fsync_do, job);
if (ret != 0) {
return ret;
}
job->busy = 1;
return 0;
}
static void asys_fsync_do(void *private_data)
{
struct asys_job *job = (struct asys_job *)private_data;
struct asys_fsync_args *args = &job->args.fsync_args;
job->ret = fsync(args->fildes);
if (job->ret == -1) {
job->err = errno;
}
}
void asys_cancel(struct asys_context *ctx, void *private_data)
{
unsigned i;