diff options
author | Haru <haru@dotalux.com> | 2018-08-27 01:14:09 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2018-08-27 01:14:09 +0200 |
commit | 5bb417009a0e8d6f0ed05a4007ea0248f7cb4138 (patch) | |
tree | 2e43dd174d737006e2bc109deabde25521a8f7c1 /src | |
parent | 483341747ac3ecec9998d989b3f05af05474ea34 (diff) | |
download | hercules-5bb417009a0e8d6f0ed05a4007ea0248f7cb4138.tar.gz hercules-5bb417009a0e8d6f0ed05a4007ea0248f7cb4138.tar.bz2 hercules-5bb417009a0e8d6f0ed05a4007ea0248f7cb4138.tar.xz hercules-5bb417009a0e8d6f0ed05a4007ea0248f7cb4138.zip |
Fix a race condition in the storage saving code
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/map/intif.c | 7 | ||||
-rw-r--r-- | src/map/intif.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/map/intif.c b/src/map/intif.c index 84fad6c6f..ed4c0e2d2 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -513,7 +513,7 @@ static void intif_parse_account_storage(int fd) * @packet 0x3011 [out] <packet_len>.W <account_id>.L <struct item[]>.P * @param sd [in] pointer to session data. */ -static void intif_send_account_storage(const struct map_session_data *sd) +static void intif_send_account_storage(struct map_session_data *sd) { int len = 0, i = 0, c = 0; @@ -541,6 +541,8 @@ static void intif_send_account_storage(const struct map_session_data *sd) } WFIFOSET(inter_fd, len); + + sd->storage.save = false; // Save request has been sent } /** @@ -562,10 +564,9 @@ static void intif_parse_account_storage_save_ack(int fd) if (saved == 0) { ShowError("intif_parse_account_storage_save_ack: Storage has not been saved! (AID: %d)\n", account_id); + sd->storage.save = true; // Flag it as unsaved, to re-attempt later return; } - - sd->storage.save = false; // Storage has been saved. } //================================================================= diff --git a/src/map/intif.h b/src/map/intif.h index 1e98d11f8..21f7a494c 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -68,7 +68,7 @@ struct intif_interface { int (*saveregistry) (struct map_session_data *sd); int (*request_registry) (struct map_session_data *sd, int flag); void (*request_account_storage) (const struct map_session_data *sd); - void (*send_account_storage) (const struct map_session_data *sd); + void (*send_account_storage) (struct map_session_data *sd); int (*request_guild_storage) (int account_id, int guild_id); int (*send_guild_storage) (int account_id, struct guild_storage *gstor); int (*create_party) (struct party_member *member, const char *name, int item, int item2); |