Don't cleanup request if callback returns MSTDNT_REQUEST_DATA_NOCLEANUP
FossilOrigin-Name: 81eb1de23d8b624fff721958ccc7506ca427bfc92214ea8f3ce388d3c5221b2e
This commit is contained in:
parent
f11802fc98
commit
d4041fc030
3 changed files with 22 additions and 10 deletions
|
@ -31,13 +31,13 @@ struct _mstdnt_accounts_args
|
|||
size_t* size;
|
||||
};
|
||||
|
||||
struct mstdnt_accounts
|
||||
typedef struct mstdnt_accounts
|
||||
{
|
||||
struct mstdnt_account* accts;
|
||||
size_t len;
|
||||
};
|
||||
} mstdnt_accounts;
|
||||
|
||||
struct mstdnt_account
|
||||
typedef struct mstdnt_account
|
||||
{
|
||||
char* id;
|
||||
char* username;
|
||||
|
@ -71,7 +71,7 @@ struct mstdnt_account
|
|||
/* struct mstdnt_source* source */
|
||||
mstdnt_bool suspended;
|
||||
char* mute_expires_at;
|
||||
};
|
||||
} mstdnt_account;
|
||||
|
||||
struct mstdnt_account_args
|
||||
{
|
||||
|
|
|
@ -30,15 +30,24 @@ typedef int8_t mstdnt_bool;
|
|||
|
||||
struct mstdnt_storage;
|
||||
|
||||
// Only god knows
|
||||
typedef void (*mstdnt_data_free_cb_t)(void*, size_t);
|
||||
typedef void (*mstdnt_request_cb_t)(void* data, void* args);
|
||||
|
||||
typedef struct mstdnt_request_cb_data {
|
||||
struct mstdnt_storage* storage;
|
||||
void* data;
|
||||
mstdnt_data_free_cb_t data_free_cb;
|
||||
} mstdnt_request_cb_data;
|
||||
|
||||
typedef void (*mstdnt_request_cb_t)(mstdnt_request_cb_data* data, void* args);
|
||||
|
||||
// Return types for mstdnt_request_cb_t, specifies
|
||||
// what we want to do with the data
|
||||
typedef enum mstdnt_enum_req
|
||||
{
|
||||
MSTDNT_REQUEST_DONE = 0,
|
||||
MSTDNT_REQUEST_DATA_NOCLEANUP = 1,
|
||||
} mstdnt_enum_req;
|
||||
|
||||
#define MSTDNT_CB_DATA(_data) (_data->data)
|
||||
#define MSTDNT_FLAG_NO_URI_SANITIZE (1<<0)
|
||||
#define MSTDNT_FLAG_SSL_UNVERIFIED (1<<1)
|
||||
|
|
11
src/fetch.c
11
src/fetch.c
|
@ -190,12 +190,15 @@ int mstdnt_await(mastodont_t* mstdnt,
|
|||
if (data->json_cb)
|
||||
res = data->json_cb(storage.root, data->json_args, &results);
|
||||
|
||||
data->callback(&(results), data->callback_args);
|
||||
res = data->callback(&(results), data->callback_args);
|
||||
|
||||
cleanup_res:
|
||||
mstdnt_request_cb_cleanup(&results);
|
||||
// Cleanup
|
||||
mstdnt_fetch_data_cleanup(data);
|
||||
if (res != MSTDNT_REQUEST_DATA_NOCLEANUP)
|
||||
{
|
||||
mstdnt_request_cb_cleanup(&results);
|
||||
// Cleanup
|
||||
mstdnt_fetch_data_cleanup(data);
|
||||
}
|
||||
curl_multi_remove_handle(mstdnt->curl, msg->easy_handle);
|
||||
curl_easy_cleanup(msg->easy_handle);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue