Add the ability to associate an opaque user pointer to a ToastyHandle which is then returned in its associated ToastyResult

This commit is contained in:
2025-11-22 23:09:31 +01:00
parent e1fa3729c6
commit b930ba08e3
3 changed files with 113 additions and 97 deletions
+6
View File
@@ -136,6 +136,11 @@ ToastyHandle toasty_begin_read(ToastyFS *toasty, ToastyString path,
ToastyHandle toasty_begin_write(ToastyFS *toasty, ToastyString path, ToastyHandle toasty_begin_write(ToastyFS *toasty, ToastyString path,
int off, void *src, int len); int off, void *src, int len);
// Associate the pointer "user" to the handle. The user
// pointer will be returned in the ToastyResult when the
// operation compltes.
void toasty_set_uesr(ToastyFS *toasty, ToastyHandle handle, void *user);
typedef enum { typedef enum {
TOASTY_RESULT_EMPTY, TOASTY_RESULT_EMPTY,
TOASTY_RESULT_CREATE_ERROR, TOASTY_RESULT_CREATE_ERROR,
@@ -153,6 +158,7 @@ typedef enum {
typedef struct { typedef struct {
ToastyResultType type; ToastyResultType type;
ToastyListing listing; ToastyListing listing;
void *user;
} ToastyResult; } ToastyResult;
// If the operation specified by "handle" is complete, // If the operation specified by "handle" is complete,
+102 -89
View File
@@ -104,6 +104,9 @@ typedef struct {
// and -1 are always invalid. // and -1 are always invalid.
uint16_t generation; uint16_t generation;
// Opaque pointer set by the user
void *user;
ToastyString path; // Only set for writes ToastyString path; // Only set for writes
void *ptr; void *ptr;
int off; int off;
@@ -260,6 +263,7 @@ alloc_operation(ToastyFS *toasty, OperationType type, int off, void *ptr, int le
assert(o < toasty->operations + MAX_OPERATIONS); assert(o < toasty->operations + MAX_OPERATIONS);
} }
o->type = type; o->type = type;
o->user = NULL;
o->ptr = ptr; o->ptr = ptr;
o->off = off; o->off = off;
o->len = len; o->len = len;
@@ -764,13 +768,22 @@ void toasty_free_result(ToastyResult *result)
toasty_free_listing(&result->listing); toasty_free_listing(&result->listing);
} }
void toasty_set_uesr(ToastyFS *toasty, ToastyHandle handle, void *user)
{
int opidx = handle_to_operation(toasty, handle);
if (opidx < 0)
return;
toasty->operations[opidx].user = user;
}
static void process_event_for_create(ToastyFS *toasty, static void process_event_for_create(ToastyFS *toasty,
int opidx, int request_tag, ByteView msg) int opidx, int request_tag, ByteView msg)
{ {
(void) request_tag; (void) request_tag;
if (msg.len == 0) { if (msg.len == 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -778,34 +791,34 @@ static void process_event_for_create(ToastyFS *toasty,
// version // version
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(type))) { if (!binary_read(&reader, &type, sizeof(type))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// length // length
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_CREATE_SUCCESS) { if (type != MESSAGE_TYPE_CREATE_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Check there is nothing else to read // Check there is nothing else to read
if (binary_read(&reader, NULL, 1)) { if (binary_read(&reader, NULL, 1)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_SUCCESS }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_CREATE_SUCCESS, .user=toasty->operations[opidx].user };
} }
static void process_event_for_delete(ToastyFS *toasty, static void process_event_for_delete(ToastyFS *toasty,
@@ -814,7 +827,7 @@ static void process_event_for_delete(ToastyFS *toasty,
(void) request_tag; (void) request_tag;
if (msg.len == 0) { if (msg.len == 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -822,34 +835,34 @@ static void process_event_for_delete(ToastyFS *toasty,
// version // version
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(type))) { if (!binary_read(&reader, &type, sizeof(type))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// length // length
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_DELETE_SUCCESS) { if (type != MESSAGE_TYPE_DELETE_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Check there is nothing else to read // Check there is nothing else to read
if (binary_read(&reader, NULL, 1)) { if (binary_read(&reader, NULL, 1)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_SUCCESS }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_DELETE_SUCCESS, .user=toasty->operations[opidx].user };
} }
static void process_event_for_list(ToastyFS *toasty, static void process_event_for_list(ToastyFS *toasty,
@@ -858,7 +871,7 @@ static void process_event_for_list(ToastyFS *toasty,
(void) request_tag; (void) request_tag;
if (msg.len == 0) { if (msg.len == 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -866,43 +879,43 @@ static void process_event_for_list(ToastyFS *toasty,
// version // version
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(type))) { if (!binary_read(&reader, &type, sizeof(type))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// length // length
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_LIST_SUCCESS) { if (type != MESSAGE_TYPE_LIST_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Read and validate the list data // Read and validate the list data
uint32_t item_count; uint32_t item_count;
if (!binary_read(&reader, &item_count, sizeof(item_count))) { if (!binary_read(&reader, &item_count, sizeof(item_count))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint8_t truncated; uint8_t truncated;
if (!binary_read(&reader, &truncated, sizeof(truncated))) { if (!binary_read(&reader, &truncated, sizeof(truncated))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
ToastyListingEntry *entities = sys_malloc(item_count * sizeof(ToastyListingEntry)); ToastyListingEntry *entities = sys_malloc(item_count * sizeof(ToastyListingEntry));
if (entities == NULL) { if (entities == NULL) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -910,21 +923,21 @@ static void process_event_for_list(ToastyFS *toasty,
for (uint32_t i = 0; i < item_count; i++) { for (uint32_t i = 0; i < item_count; i++) {
uint8_t is_dir; uint8_t is_dir;
if (!binary_read(&reader, &is_dir, sizeof(is_dir))) { if (!binary_read(&reader, &is_dir, sizeof(is_dir))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
sys_free(entities); sys_free(entities);
return; return;
} }
uint16_t name_len; uint16_t name_len;
if (!binary_read(&reader, &name_len, sizeof(name_len))) { if (!binary_read(&reader, &name_len, sizeof(name_len))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
sys_free(entities); sys_free(entities);
return; return;
} }
char *name = (char*) reader.src + reader.cur; char *name = (char*) reader.src + reader.cur;
if (!binary_read(&reader, NULL, name_len)) { if (!binary_read(&reader, NULL, name_len)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
sys_free(entities); sys_free(entities);
return; return;
} }
@@ -932,7 +945,7 @@ static void process_event_for_list(ToastyFS *toasty,
entities[i].is_dir = is_dir; entities[i].is_dir = is_dir;
if (name_len > sizeof(entities[i].name)-1) { if (name_len > sizeof(entities[i].name)-1) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
sys_free(entities); sys_free(entities);
return; return;
} }
@@ -942,19 +955,19 @@ static void process_event_for_list(ToastyFS *toasty,
// Check there is nothing else to read // Check there is nothing else to read
if (binary_read(&reader, NULL, 1)) { if (binary_read(&reader, NULL, 1)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_ERROR, .user=toasty->operations[opidx].user };
sys_free(entities); sys_free(entities);
return; return;
} }
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_SUCCESS, .listing=(ToastyListing) { item_count, entities } }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_LIST_SUCCESS, .user=toasty->operations[opidx].user, .listing=(ToastyListing) { item_count, entities } };
} }
static void process_event_for_read(ToastyFS *toasty, static void process_event_for_read(ToastyFS *toasty,
int opidx, int request_tag, ByteView msg) int opidx, int request_tag, ByteView msg)
{ {
if (msg.len == 0) { if (msg.len == 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -964,32 +977,32 @@ static void process_event_for_read(ToastyFS *toasty,
// Skip version // Skip version
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Check message type // Check message type
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(type))) { if (!binary_read(&reader, &type, sizeof(type))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_READ_SUCCESS) { if (type != MESSAGE_TYPE_READ_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Skip message length // Skip message length
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Read chunk size // Read chunk size
uint32_t chunk_size; uint32_t chunk_size;
if (!binary_read(&reader, &chunk_size, sizeof(chunk_size))) { if (!binary_read(&reader, &chunk_size, sizeof(chunk_size))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -998,7 +1011,7 @@ static void process_event_for_read(ToastyFS *toasty,
int len = toasty->operations[opidx].len; int len = toasty->operations[opidx].len;
if (len == 0) { if (len == 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_SUCCESS }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_SUCCESS, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1011,14 +1024,14 @@ static void process_event_for_read(ToastyFS *toasty,
// Read number of hashes // Read number of hashes
uint32_t num_hashes; uint32_t num_hashes;
if (!binary_read(&reader, &num_hashes, sizeof(num_hashes))) { if (!binary_read(&reader, &num_hashes, sizeof(num_hashes))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// Allocate ranges // Allocate ranges
Range *ranges = sys_malloc(num_chunks_needed * sizeof(Range)); Range *ranges = sys_malloc(num_chunks_needed * sizeof(Range));
if (ranges == NULL) { if (ranges == NULL) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1032,7 +1045,7 @@ static void process_event_for_read(ToastyFS *toasty,
SHA256 hash; SHA256 hash;
if (!binary_read(&reader, &hash, sizeof(hash))) { if (!binary_read(&reader, &hash, sizeof(hash))) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1040,7 +1053,7 @@ static void process_event_for_read(ToastyFS *toasty,
uint32_t num_servers; uint32_t num_servers;
if (!binary_read(&reader, &num_servers, sizeof(num_servers))) { if (!binary_read(&reader, &num_servers, sizeof(num_servers))) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1048,7 +1061,7 @@ static void process_event_for_read(ToastyFS *toasty,
uint32_t num_ipv4; uint32_t num_ipv4;
if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4))) { if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4))) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1062,7 +1075,7 @@ static void process_event_for_read(ToastyFS *toasty,
if (!binary_read(&reader, &ipv4, sizeof(ipv4)) || if (!binary_read(&reader, &ipv4, sizeof(ipv4)) ||
!binary_read(&reader, &port, sizeof(port))) { !binary_read(&reader, &port, sizeof(port))) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (!found) { if (!found) {
@@ -1077,21 +1090,21 @@ static void process_event_for_read(ToastyFS *toasty,
uint32_t num_ipv6; uint32_t num_ipv6;
if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6))) { if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6))) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
for (uint32_t j = 0; j < num_ipv6; j++) { for (uint32_t j = 0; j < num_ipv6; j++) {
if (!binary_read(&reader, NULL, sizeof(IPv6)) || if (!binary_read(&reader, NULL, sizeof(IPv6)) ||
!binary_read(&reader, NULL, sizeof(uint16_t))) { !binary_read(&reader, NULL, sizeof(uint16_t))) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
} }
if (!found) { if (!found) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1136,7 +1149,7 @@ static void process_event_for_read(ToastyFS *toasty,
int cs_idx = get_chunk_server(toasty, &r->server_addr, 1, NULL); int cs_idx = get_chunk_server(toasty, &r->server_addr, 1, NULL);
if (cs_idx < 0) { if (cs_idx < 0) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
r->chunk_server_idx = cs_idx; r->chunk_server_idx = cs_idx;
@@ -1144,7 +1157,7 @@ static void process_event_for_read(ToastyFS *toasty,
if (send_download_chunk(toasty, cs_idx, r->hash, r->offset_within_chunk, if (send_download_chunk(toasty, cs_idx, r->hash, r->offset_within_chunk,
r->length_within_chunk, opidx, 0) < 0) { r->length_within_chunk, opidx, 0) < 0) {
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1153,7 +1166,7 @@ static void process_event_for_read(ToastyFS *toasty,
} else { } else {
// No chunks to download // No chunks to download
sys_free(ranges); sys_free(ranges);
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_SUCCESS }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_SUCCESS, .user=toasty->operations[opidx].user };
} }
} else { } else {
@@ -1164,40 +1177,40 @@ static void process_event_for_read(ToastyFS *toasty,
// Parse response // Parse response
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(type))) { if (!binary_read(&reader, &type, sizeof(type))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_DOWNLOAD_CHUNK_SUCCESS) { if (type != MESSAGE_TYPE_DOWNLOAD_CHUNK_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint32_t data_len; uint32_t data_len;
if (!binary_read(&reader, &data_len, sizeof(data_len))) { if (!binary_read(&reader, &data_len, sizeof(data_len))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint8_t *data = reader.src + reader.cur; uint8_t *data = reader.src + reader.cur;
if (!binary_read(&reader, NULL, data_len)) { if (!binary_read(&reader, NULL, data_len)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (binary_read(&reader, NULL, 1)) { if (binary_read(&reader, NULL, 1)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1228,7 +1241,7 @@ static void process_event_for_read(ToastyFS *toasty,
if (toasty->operations[opidx].num_pending == 0) { if (toasty->operations[opidx].num_pending == 0) {
sys_free(toasty->operations[opidx].ranges); sys_free(toasty->operations[opidx].ranges);
toasty->operations[opidx].ranges = NULL; toasty->operations[opidx].ranges = NULL;
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_SUCCESS }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_READ_SUCCESS, .user=toasty->operations[opidx].user };
} }
} }
} }
@@ -1376,7 +1389,7 @@ static void process_event_for_write(ToastyFS *toasty,
int opidx, int request_tag, ByteView msg) int opidx, int request_tag, ByteView msg)
{ {
if (msg.len == 0) { if (msg.len == 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1385,36 +1398,36 @@ static void process_event_for_write(ToastyFS *toasty,
BinaryReader reader = { msg.ptr, msg.len, 0 }; BinaryReader reader = { msg.ptr, msg.len, 0 };
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(type))) { if (!binary_read(&reader, &type, sizeof(type))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_READ_SUCCESS) { if (type != MESSAGE_TYPE_READ_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint32_t chunk_size; uint32_t chunk_size;
if (!binary_read(&reader, &chunk_size, sizeof(chunk_size))) { if (!binary_read(&reader, &chunk_size, sizeof(chunk_size))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
toasty->operations[opidx].chunk_size = chunk_size; toasty->operations[opidx].chunk_size = chunk_size;
uint32_t num_hashes; uint32_t num_hashes;
if (!binary_read(&reader, &num_hashes, sizeof(num_hashes))) { if (!binary_read(&reader, &num_hashes, sizeof(num_hashes))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1461,7 +1474,7 @@ static void process_event_for_write(ToastyFS *toasty,
SHA256 hash; SHA256 hash;
if (!binary_read(&reader, &hash, sizeof(hash))) { if (!binary_read(&reader, &hash, sizeof(hash))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1469,7 +1482,7 @@ static void process_event_for_write(ToastyFS *toasty,
uint32_t num_holders; uint32_t num_holders;
if (!binary_read(&reader, &num_holders, sizeof(num_holders))) { if (!binary_read(&reader, &num_holders, sizeof(num_holders))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1480,7 +1493,7 @@ static void process_event_for_write(ToastyFS *toasty,
uint32_t num_ipv4; uint32_t num_ipv4;
if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4))) { if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1488,13 +1501,13 @@ static void process_event_for_write(ToastyFS *toasty,
IPv4 ipv4; IPv4 ipv4;
if (!binary_read(&reader, &ipv4, sizeof(ipv4))) { if (!binary_read(&reader, &ipv4, sizeof(ipv4))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t port; uint16_t port;
if (!binary_read(&reader, &port, sizeof(port))) { if (!binary_read(&reader, &port, sizeof(port))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1509,14 +1522,14 @@ static void process_event_for_write(ToastyFS *toasty,
upload.off = off; upload.off = off;
upload.len = len; upload.len = len;
if (schedule_upload(toasty, opidx, upload) < 0) { if (schedule_upload(toasty, opidx, upload) < 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
} }
uint32_t num_ipv6; uint32_t num_ipv6;
if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6))) { if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1524,13 +1537,13 @@ static void process_event_for_write(ToastyFS *toasty,
IPv6 ipv6; IPv6 ipv6;
if (!binary_read(&reader, &ipv6, sizeof(ipv6))) { if (!binary_read(&reader, &ipv6, sizeof(ipv6))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t port; uint16_t port;
if (!binary_read(&reader, &port, sizeof(port))) { if (!binary_read(&reader, &port, sizeof(port))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1545,7 +1558,7 @@ static void process_event_for_write(ToastyFS *toasty,
upload.off = off; upload.off = off;
upload.len = len; upload.len = len;
if (schedule_upload(toasty, opidx, upload) < 0) { if (schedule_upload(toasty, opidx, upload) < 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
} }
@@ -1554,7 +1567,7 @@ static void process_event_for_write(ToastyFS *toasty,
uint32_t num_locations; uint32_t num_locations;
if (!binary_read(&reader, &num_locations, sizeof(num_locations))) { if (!binary_read(&reader, &num_locations, sizeof(num_locations))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1565,7 +1578,7 @@ static void process_event_for_write(ToastyFS *toasty,
uint32_t num_ipv4; uint32_t num_ipv4;
if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4))) { if (!binary_read(&reader, &num_ipv4, sizeof(num_ipv4))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1573,13 +1586,13 @@ static void process_event_for_write(ToastyFS *toasty,
IPv4 ipv4; IPv4 ipv4;
if (!binary_read(&reader, &ipv4, sizeof(ipv4))) { if (!binary_read(&reader, &ipv4, sizeof(ipv4))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t port; uint16_t port;
if (!binary_read(&reader, &port, sizeof(port))) { if (!binary_read(&reader, &port, sizeof(port))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
#if 0 #if 0
@@ -1620,7 +1633,7 @@ static void process_event_for_write(ToastyFS *toasty,
upload.off = off; upload.off = off;
upload.len = len; upload.len = len;
if (schedule_upload(toasty, opidx, upload) < 0) { if (schedule_upload(toasty, opidx, upload) < 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
} }
@@ -1630,7 +1643,7 @@ static void process_event_for_write(ToastyFS *toasty,
uint32_t num_ipv6; uint32_t num_ipv6;
if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6))) { if (!binary_read(&reader, &num_ipv6, sizeof(num_ipv6))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1640,13 +1653,13 @@ static void process_event_for_write(ToastyFS *toasty,
IPv6 ipv6; IPv6 ipv6;
if (!binary_read(&reader, &ipv6, sizeof(ipv6))) { if (!binary_read(&reader, &ipv6, sizeof(ipv6))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t port; uint16_t port;
if (!binary_read(&reader, &port, sizeof(port))) { if (!binary_read(&reader, &port, sizeof(port))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
#if 0 #if 0
@@ -1685,7 +1698,7 @@ static void process_event_for_write(ToastyFS *toasty,
upload.off = off; upload.off = off;
upload.len = len; upload.len = len;
if (schedule_upload(toasty, opidx, upload) < 0) { if (schedule_upload(toasty, opidx, upload) < 0) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
} }
@@ -1703,7 +1716,7 @@ static void process_event_for_write(ToastyFS *toasty,
if (started == 0) { if (started == 0) {
// We already failed // We already failed
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
@@ -1881,7 +1894,7 @@ static void process_event_for_write(ToastyFS *toasty,
} }
if (!ok) { if (!ok) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
free(upload_results); free(upload_results);
return; return;
} }
@@ -1944,33 +1957,33 @@ static void process_event_for_write(ToastyFS *toasty,
// version // version
if (!binary_read(&reader, NULL, sizeof(uint16_t))) { if (!binary_read(&reader, NULL, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
uint16_t type; uint16_t type;
if (!binary_read(&reader, &type, sizeof(uint16_t))) { if (!binary_read(&reader, &type, sizeof(uint16_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
// length // length
if (!binary_read(&reader, NULL, sizeof(uint32_t))) { if (!binary_read(&reader, NULL, sizeof(uint32_t))) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (binary_read(&reader, NULL, 1)) { if (binary_read(&reader, NULL, 1)) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
if (type != MESSAGE_TYPE_WRITE_SUCCESS) { if (type != MESSAGE_TYPE_WRITE_SUCCESS) {
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_ERROR, .user=toasty->operations[opidx].user };
return; return;
} }
toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_SUCCESS }; toasty->operations[opidx].result = (ToastyResult) { .type=TOASTY_RESULT_WRITE_SUCCESS, .user=toasty->operations[opidx].user };
} }
} }
+5 -8
View File
@@ -133,12 +133,8 @@ int main(void)
// Completed // Completed
assert(ret == 0); assert(ret == 0);
// Find the operation associated to this completion int i = (ProxiedOperation*) result.user - proxied;
int i = 0; assert(i > -1 && i < MAX_PROXIED_OPERATIONS);
while (proxied[i].handle != result.handle) {
i++;
assert(i < MAX_PROXIED_OPERATIONS);
}
switch (proxied[i].type) { switch (proxied[i].type) {
case PROXIED_OPERATION_CREATE_DIR: case PROXIED_OPERATION_CREATE_DIR:
@@ -176,8 +172,7 @@ int main(void)
http_response_builder_status(proxied[i].builder, 200); http_response_builder_status(proxied[i].builder, 200);
for (int i = 0; i < result.listing.count; i++) for (int i = 0; i < result.listing.count; i++)
http_response_builder_body(proxied[i].builder, (HTTP_String) { http_response_builder_body(proxied[i].builder, (HTTP_String) {
result.listing.items[i].name, result.listing.items[i].name, strlen(result.listing.items[i].name),
result.listing.items[i].name_len
}); });
http_response_builder_send(proxied[i].builder); http_response_builder_send(proxied[i].builder);
toasty_free_listing(&result.listing); toasty_free_listing(&result.listing);
@@ -289,6 +284,7 @@ int main(void)
break; break;
} }
toasty_set_user(toasty, handle, &proxied[num_proxied]);
proxied[num_proxied].type = PROXIED_OPERATION_WRITE; proxied[num_proxied].type = PROXIED_OPERATION_WRITE;
proxied[num_proxied].request = request; proxied[num_proxied].request = request;
proxied[num_proxied].builder = builder; proxied[num_proxied].builder = builder;
@@ -312,6 +308,7 @@ int main(void)
break; break;
} }
toasty_set_user(toasty, handle, &proxied[num_proxied]);
proxied[num_proxied].type = PROXIED_OPERATION_DELETE; proxied[num_proxied].type = PROXIED_OPERATION_DELETE;
proxied[num_proxied].request = request; proxied[num_proxied].request = request;
proxied[num_proxied].builder = builder; proxied[num_proxied].builder = builder;