Skip to content

Commit d00c4e0

Browse files
authored
feat: correctly handle eof and resolve crash with EVT (#508)
Signed-off-by: Michael Pollind <[email protected]>
1 parent 4ac69c7 commit d00c4e0

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

source/steamshim/src/parent/parent.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ static bool setEnvironmentVars( PipeType pipeChildRead, PipeType pipeChildWrite
9090

9191
void taskHeartbeat()
9292
{
93-
while( true ) {
93+
while (STEAMSHIM_active()) {
9494
struct steam_shim_common_s pkt;
9595
pkt.cmd = EVT_HEART_BEAT;
96-
STEAMSHIM_sendEVT( &pkt, sizeof( struct steam_shim_common_s ) );
96+
STEAMSHIM_sendEVT( &pkt, sizeof( struct steam_shim_common_s ));
9797
std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
9898
}
9999
}
@@ -162,9 +162,8 @@ int STEAMSHIM_init( SteamshimOptions *options )
162162
void STEAMSHIM_deinit( void )
163163
{
164164
dbgprintf( "Child deinit.\n" );
165-
if( GPipeWrite != NULLPIPE ) {
165+
if( GPipeWrite != NULLPIPE )
166166
closePipe( GPipeWrite );
167-
}
168167

169168
if( GPipeRead != NULLPIPE )
170169
closePipe( GPipeRead );
@@ -224,7 +223,7 @@ int STEAMSHIM_waitDispatchSync( uint32_t syncIndex )
224223
if( bytesRead > 0 ) {
225224
cursor += bytesRead;
226225
} else {
227-
continue;
226+
return -1;
228227
}
229228
continue_processing:
230229

@@ -279,7 +278,7 @@ void STEAMSHIM_subscribeEvent( uint32_t id, void *self, STEAMSHIM_evt_handle evt
279278
void STEAMSHIM_unsubscribeEvent( uint32_t id, STEAMSHIM_evt_handle cb )
280279
{
281280
assert( id >= EVT_BEGIN && id < EVT_END );
282-
struct event_subscriber_s *handle = evt_handles + ( EVT_BEGIN - id );
281+
struct event_subscriber_s *handle = evt_handles + ( id - EVT_BEGIN );
283282
size_t ib = 0;
284283
size_t ic = 0;
285284
const size_t len = handle->numSubscribers;

source/steamshim/src/parent/parent.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ freely, subject to the following restrictions:
2525
#include "../steamshim.h"
2626
#include "../steamshim_types.h"
2727

28-
29-
3028
typedef struct {
3129
bool debug;
3230
bool runclient;

0 commit comments

Comments
 (0)