Hi Henrik,
> So I made a change that would prevent (throw "http) to be called and
> everything worked.
Great!
> ...
> (if *Xml
> (setq *Xml
> (ht:Read *ContLen))
> (cond
> (*MPartLim (_htMultipart))
> ((if *ContLen (ht:Read @) (line))
> (for L (split @ '&)
> ...
Just a side note: The 'if' and 'cond' might better be merged to a single
'cond':
...
(cond
(*Xml (setq *Xml (ht:Read *ContLen)))
(*MPartLim (_htMultipart))
((if *ContLen (ht:Read @) (line))
(for L (split @ '&)
...
> Could it be as simple as: (task (port 4000) (load "hubimport.l")) and
> then do whatever it is I want to do in the hubimport.l file? Like
Yes, but - as you know - if that code accesses the database, it should
run as a sister process to other DB processes. So it should either do a
(fork) on each transaction, or do a (fork) on startup and handle
requests in a permanent child process.
1. Fork for each transaction:
(task (port 4000) # Background task listening on port 4000
(when (setq Sock (accept @)) # Accept a connection
(unless (fork) # Child process
(task P)
(close P) # Close port in child process
(in Sock
(match ...) # Read payload data
(ht:Read ...)
(dosomething) )
(bye) ) # Exit child process
(close Sock) ) ) # Close socket in parent process
2. Handle requests in a permanent child:
(unless (fork) # Start a permanent child process
(task (port 4000)
(let? Sock (accept @)
(in Sock
(match ...) # Read payload data
(ht:Read ...)
(dosomething) )
(close Sock) ) )
(wait) ) # Wait in the background event loop
I would probably go with 1), as this is more stable and modular. If a
child crashes or hangs, it does not disturb the rest of the system.
Also, more than one request can be handled at a time.
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe