int tsocket_simple_int_recv(struct tevent_req *req, int *perrno) { enum tevent_req_state state; uint64_t error; if (!tevent_req_is_error(req, &state, &error)) { return 0; } switch (state) { case TEVENT_REQ_NO_MEMORY: *perrno = ENOMEM; return -1; case TEVENT_REQ_TIMED_OUT: *perrno = ETIMEDOUT; return -1; case TEVENT_REQ_USER_ERROR: *perrno = (int)error; return -1; default: *perrno = EIO; return -1; } *perrno = EIO; return -1; }
static void ldap_id_enumerate_reschedule(struct tevent_req *req) { struct sdap_id_ctx *ctx = tevent_req_callback_data(req, struct sdap_id_ctx); enum tevent_req_state tstate; uint64_t err; struct timeval tv; int delay; errno_t ret; if (tevent_req_is_error(req, &tstate, &err)) { /* On error schedule starting from now, not the last run */ tv = tevent_timeval_current(); } else { tv = ctx->last_enum; /* Ok, we've completed an enumeration. Save this to the * sysdb so we can postpone starting up the enumeration * process on the next SSSD service restart (to avoid * slowing down system boot-up */ ret = sysdb_set_enumerated(ctx->be->sysdb, true); if (ret != EOK) { DEBUG(1, ("Could not mark domain as having enumerated.\n")); /* This error is non-fatal, so continue */ } } talloc_zfree(req); delay = dp_opt_get_int(ctx->opts->basic, SDAP_ENUM_REFRESH_TIMEOUT); tv = tevent_timeval_add(&tv, delay, 0); ldap_id_enumerate_set_timer(ctx, tv); }
bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err) { enum tevent_req_state state; uint64_t error; if (!tevent_req_is_error(req, &state, &error)) { *pwbc_err = WBC_ERR_SUCCESS; return false; } switch (state) { case TEVENT_REQ_USER_ERROR: *pwbc_err = error; break; case TEVENT_REQ_TIMED_OUT: *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; break; case TEVENT_REQ_NO_MEMORY: *pwbc_err = WBC_ERR_NO_MEMORY; break; default: *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; break; } return true; }
static NTSTATUS smbd_smb2_ioctl_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, DATA_BLOB *out_output, bool *disconnect) { NTSTATUS status = NT_STATUS_OK; struct smbd_smb2_ioctl_state *state = tevent_req_data(req, struct smbd_smb2_ioctl_state); enum tevent_req_state req_state; uint64_t err; *disconnect = state->disconnect; if ((tevent_req_is_error(req, &req_state, &err) == false) || (req_state == TEVENT_REQ_USER_ERROR)) { /* * Return output buffer to caller if the ioctl was successfully * processed, even if a user error occurred. Some ioctls return * data on failure. */ *out_output = state->out_output; talloc_steal(mem_ctx, out_output->data); } tevent_req_is_nterror(req, &status); tevent_req_received(req); return status; }
bool tevent_req_is_unix_error(struct tevent_req *req, int *perrno) { enum tevent_req_state state; uint64_t err; if (!tevent_req_is_error(req, &state, &err)) { return false; } switch (state) { case TEVENT_REQ_TIMED_OUT: *perrno = ETIMEDOUT; break; case TEVENT_REQ_NO_MEMORY: *perrno = ENOMEM; break; case TEVENT_REQ_USER_ERROR: *perrno = err; break; default: *perrno = EINVAL; break; } return true; }
bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *status) { enum tevent_req_state state; uint64_t err; if (!tevent_req_is_error(req, &state, &err)) { return false; } switch (state) { case TEVENT_REQ_TIMED_OUT: *status = NT_STATUS_IO_TIMEOUT; break; case TEVENT_REQ_NO_MEMORY: *status = NT_STATUS_NO_MEMORY; break; case TEVENT_REQ_USER_ERROR: *status = NT_STATUS(err); break; default: *status = NT_STATUS_INTERNAL_ERROR; break; } return true; }