static int uwsgi_rados_delete(struct wsgi_request *wsgi_req, rados_ioctx_t ctx, char *key, int timeout) { if (uwsgi.async < 1) { return rados_remove(ctx, key); } struct uwsgi_rados_io *urio = &urados.urio[wsgi_req->async_id]; int ret = -1; // increase request counter pthread_mutex_lock(&urio->mutex); urio->rid++; pthread_mutex_unlock(&urio->mutex); struct uwsgi_rados_cb *urcb = uwsgi_malloc(sizeof(struct uwsgi_rados_cb)); // map the current request id to the callback urcb->rid = urio->rid; // map urio to the callback urcb->urio = urio; rados_completion_t comp; // we use the safe cb here if (rados_aio_create_completion(urcb, NULL, uwsgi_rados_read_async_cb, &comp) < 0) { free(urcb); goto end; } if (rados_aio_remove(ctx, key, comp) < 0) { free(urcb); rados_aio_release(comp); goto end; } // wait for the callback to be executed if (uwsgi.wait_read_hook(urio->fds[0], timeout) <= 0) { rados_aio_release(comp); goto end; } char ack = 1; if (read(urio->fds[0], &ack, 1) != 1) { rados_aio_release(comp); uwsgi_error("uwsgi_rados_delete()/read()"); goto end; } if (rados_aio_is_safe_and_cb(comp)) { ret = rados_aio_get_return_value(comp); } rados_aio_release(comp); end: return ret; }
static int rados_metatile_delete(struct storage_backend * store, const char *xmlconfig, int x, int y, int z) { struct rados_ctx * ctx = (struct rados_ctx *)store->storage_ctx; char meta_path[PATH_MAX]; char tmp[PATH_MAX]; int err; //TODO: deal with options const char *options = ""; rados_xyzo_to_storagekey(xmlconfig, options, x, y, z, meta_path); err = rados_remove(ctx->io, meta_path); if (err < 0) { log_message(STORE_LOGLVL_ERR, "failed to delete %s: %s\n", rados_tile_storage_id(store, xmlconfig, options, x, y, z, tmp), strerror(-err)); return -1; } return 0; }