mirror of
https://github.com/libretro/RetroArch
synced 2025-02-13 12:40:47 +00:00
Use autosave_lock and autosave_unlock during SRAM negotiation
The SRAM transfer in netplay handshake now uses autosave_lock and autosave_unlock. Will possibly fix a hang/crash bug on Android with netplay and autosave conflicting.
This commit is contained in:
parent
e3e8796b2b
commit
a0f236a83f
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "netplay_private.h"
|
#include "netplay_private.h"
|
||||||
|
|
||||||
|
#include "../../autosave.h"
|
||||||
#include "../../configuration.h"
|
#include "../../configuration.h"
|
||||||
#include "../../content.h"
|
#include "../../content.h"
|
||||||
#include "../../retroarch.h"
|
#include "../../retroarch.h"
|
||||||
@ -508,8 +509,10 @@ bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *conne
|
|||||||
int matchct;
|
int matchct;
|
||||||
bool nick_matched;
|
bool nick_matched;
|
||||||
|
|
||||||
|
autosave_lock();
|
||||||
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
||||||
core_get_memory(&mem_info);
|
core_get_memory(&mem_info);
|
||||||
|
autosave_unlock();
|
||||||
|
|
||||||
/* Send basic sync info */
|
/* Send basic sync info */
|
||||||
cmd[0] = htonl(NETPLAY_CMD_SYNC);
|
cmd[0] = htonl(NETPLAY_CMD_SYNC);
|
||||||
@ -578,11 +581,16 @@ bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *conne
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* And finally, the SRAM */
|
/* And finally, the SRAM */
|
||||||
|
autosave_lock();
|
||||||
if (!netplay_send(&connection->send_packet_buffer, connection->fd,
|
if (!netplay_send(&connection->send_packet_buffer, connection->fd,
|
||||||
mem_info.data, mem_info.size) ||
|
mem_info.data, mem_info.size) ||
|
||||||
!netplay_send_flush(&connection->send_packet_buffer, connection->fd,
|
!netplay_send_flush(&connection->send_packet_buffer, connection->fd,
|
||||||
false))
|
false))
|
||||||
|
{
|
||||||
|
autosave_unlock();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
autosave_unlock();
|
||||||
|
|
||||||
/* Now we're ready! */
|
/* Now we're ready! */
|
||||||
connection->mode = NETPLAY_CONNECTION_SPECTATING;
|
connection->mode = NETPLAY_CONNECTION_SPECTATING;
|
||||||
@ -938,6 +946,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now check the SRAM */
|
/* Now check the SRAM */
|
||||||
|
autosave_lock();
|
||||||
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
||||||
core_get_memory(&mem_info);
|
core_get_memory(&mem_info);
|
||||||
|
|
||||||
@ -951,6 +960,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
{
|
{
|
||||||
RARCH_ERR("%s\n",
|
RARCH_ERR("%s\n",
|
||||||
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST));
|
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST));
|
||||||
|
autosave_unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,6 +975,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
{
|
{
|
||||||
RARCH_ERR("%s\n",
|
RARCH_ERR("%s\n",
|
||||||
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST));
|
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_SRAM_DATA_FROM_HOST));
|
||||||
|
autosave_unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (remote_sram_size > sizeof(uint32_t))
|
if (remote_sram_size > sizeof(uint32_t))
|
||||||
@ -974,6 +985,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
autosave_unlock();
|
||||||
|
|
||||||
/* We're ready! */
|
/* We're ready! */
|
||||||
*had_input = true;
|
*had_input = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user