mirror of
https://github.com/KarnerF/SMPlusGui.git
synced 2026-10-06 15:00:22 +02:00
Fix auto-start: check port 10101 instead of stale debug.log
This commit is contained in:
1 parent
10ec9505e3
commit
980218f294
1 file changed
+14
-2
@@ -2560,8 +2560,20 @@ int payload_main(void) {
|
||||
as_done=1;
|
||||
SMPrefs prefs; read_prefs(&prefs);
|
||||
if(prefs.auto_start){
|
||||
char sv[64]; get_sm_version(sv,sizeof(sv));
|
||||
if(strcmp(sv,"nicht aktiv")==0){
|
||||
/* check SM running via API port — not debug.log which may have stale data */
|
||||
int sm_up=0;
|
||||
int ts=socket(AF_INET,SOCK_STREAM,0);
|
||||
if(ts>=0){
|
||||
struct timeval tv={1,0};
|
||||
setsockopt(ts,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof(tv));
|
||||
setsockopt(ts,SOL_SOCKET,SO_SNDTIMEO,&tv,sizeof(tv));
|
||||
struct sockaddr_in ta; memset(&ta,0,sizeof(ta));
|
||||
ta.sin_family=AF_INET; ta.sin_port=htons(10101);
|
||||
ta.sin_addr.s_addr=inet_addr("127.0.0.1");
|
||||
if(connect(ts,(struct sockaddr*)&ta,sizeof(ta))==0) sm_up=1;
|
||||
close(ts);
|
||||
}
|
||||
if(!sm_up){
|
||||
char elf[SM_EPATH]={0};
|
||||
if(prefs.preferred_elf[0]) strncpy(elf,prefs.preferred_elf,SM_EPATH-1);
|
||||
else{ char elfs[SM_MAX_ELFS][SM_EPATH]; if(sm_find_elfs(elfs)>0) strncpy(elf,elfs[0],SM_EPATH-1); }
|
||||
|
||||
Reference in new issue
Block a user