mIRC Home    About    Download    Register    News    Help

Print Thread
/url in socket event clears $sockname (context) #265736 10/07/19 08:31 PM
Joined: Jan 2004
Posts: 1,273
L
Loki12583 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,273
I can only imagine this bug is not limited to socket events nor $sockname, but using /url within at least sockread and sockclose causes $sockname to be unset. I have not tested beyond these cases. I've also noted that context is switched after the /url call. The sockclose event runs before the next line in sockread after /url. I can somewhat understand how identifiers would be lost with this context switch, but not why the switch happens in the first place.

Workaround for possible side effects due to context swtich - always call /url from a timer?

Code
alias test {
  sockopen -e url_sock www.google.com 443
}

on *:sockopen:url_sock:{
  sockwrite -n $sockname GET / HTTP/1.0
  sockwrite -n $sockname Host: google.com
  sockwrite -n $sockname User-Agent: mIRC
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname $crlf
}

on *:sockread:url_sock:{
  sockread -f %read
  if (%read == The document has moved) {
    echo 4 -ag sockread: $!sockname = $sockname
    url www.yahoo.com
    echo 4 -ag sockread: $!sockname = $sockname
  }
}

on *:sockclose:url_sock:{
  echo 3 -ag sockclose: $!sockname = $sockname
  url www.yahoo.com
  echo 3 -ag sockclose: $!sockname = $sockname
}


Quote
sockread:  $sockname = url_sock
sockclose: $sockname = url_sock
sockclose: $sockname =

sockread:  $sockname =

Re: /url in socket event clears $sockname (context) [Re: Loki12583] #265738 11/07/19 08:54 AM
Joined: Dec 2002
Posts: 4,484
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,484
Thanks for your bug report. The /url command calls ShellExecute() which seems to trigger a sequence of windows events outside of the current event, probably related to DDE. I will look into this in a future version. In the meantime, you will need to use /timer.

Update: It looks like Firefox had a similar issue a few years ago with ShellExecute(). The same solution might apply in this case.

Last edited by Khaled; 11/07/19 10:24 AM.
Re: /url in socket event clears $sockname (context) [Re: Loki12583] #265748 12/07/19 12:18 PM
Joined: Dec 2002
Posts: 4,484
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,484
I have made a change in the latest beta that affects a number of features that use ShellExecute(), such as /run, /url, opening the Received Files folder, and so on. This appears to resolve this issue.