YottaDB / YDB

Mirrored from https://gitlab.com/YottaDB/DB/YDB
Other
76 stars 37 forks source link

WRITE /WAIT(n) doesn't wait when invoked via JOB command (perhaps Linux Kernel issue?) #121

Closed shabiel closed 6 years ago

shabiel commented 6 years ago

This example program causes the CPU to spin at 100%. Doesn't happen if run in the foreground.

If you save the routine as TEST, then D GTM^TEST(9100) will wait appropriately at WRITE /WAIT(n).

However, J GTM^TEST(9100) will spin.

GTM(SOCK) ;GT.M multi-threaded server;2018-01-02  8:56 AM
 S $ZINT="I $$JOBEXAM^ZSY($ZPOSITION)"
 K ^TMP("ZISTCP",$J)
 S ^SAM=1
 ;
 S NIO="SCK$"_SOCK
 ;
 ; Open the device
 O NIO:(LISTEN=SOCK_":TCP":ATTACH="server"):2:"SOCKET"
 I '$T QUIT
 ;
 ; Use Device
 U NIO S NIO("ZISTCP",0)=$KEY
 ;
 ;Start Listening
 W /LISTEN(5) S NIO("ZISTCP",1)=$KEY
 S POP=0
 F  D  Q:POP
 . S POP=$$EXIT ; Exit?
 . Q:POP        ; oh okay, exit.
 . W /WAIT(5)   ; Wait for connect
 . Q:$KEY=""    ; no connection; loop around, and check if we need to shut down.
 . N CHILDSOCK S CHILDSOCK=$P($KEY,"|",2) ; child socket from server.
 . U NIO:(detach=CHILDSOCK) ; detach it so that we can job it off.
 . S NIO("ZISTCP",2)=$KEY
 . S NIO("SOCK")=$P($G(NIO("ZISTCP",2)),"|",2)
 QUIT
 ;
EXIT() ;See if time to exit
 Q 0
FOIA201712>w $ZV
GT.M V6.3-002 Linux x86_64
FOIA201712>w $ZYRE
YottaDB r1.10 Linux x86_64
FOIA201712>zsy "uname -a"
Linux ibis 3.10.0-693.11.1.el7.x86_64 #1 SMP Mon Dec 4 23:52:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
shabiel commented 6 years ago

Sorry. Bad report. Don't investigate. The problem was that the Interrupt was opening a device but not properly restoring $IO.