So I've come up with the below:

(de go ()
   (rollback)
   (task (port 4000)  # Background task listening on port 4000
      (let? Sock (accept @)  # Accept a connection
         (unless (fork)  # Child process
            (in Sock
               (off *Xml *ContLen)
               (use (L @X @Y)
          # copy paste from _htHead start
                  (while (setq L (line))
                     (cond
                        ((match '(@Y "a" "t" "o" "m" @X) L)
                           (setq *Xml T))
                        ((match '(~(chop "conte...@ength: ") . @X) L)
                           (setq *ContLen (format (pack @X))))))         # =
end
                  (cond
                     (*Xml
                        (hubSubImport> '+Rss (ht:Read *ContLen))
                        (httpStat 204 "No Content"))
                     ((if *ContLen (ht:Read @) (line))
      # copy paste from http start
                        (for L (split @ '&)
                           (when (cdr (setq L (split L "=3D")))
                              (_htSet (car L) (ht:Pack (cadr L)))))
      #end
                        (httpHead "text/plain; charset=3Dutf-8")
                        (and
                           (=3D "vizual" (req 'hub.verify_token))
                           (=3D "subscribe" (req 'hub.mode))
                           (db 'xmlUrl '+Feed (req 'hub.topic))
                           (prin (req 'hub.challenge))))
                     (T (http404)))))
            (bye))  # Exit child process
         (close Sock)))  # Close socket in parent process
   (server *UsePort "@start"))

Observe the copy paste areas from (_htHead) and (http), the one I
wonder about is the part where a "normal" request would be split and
its keys =3D> values would parsed. Is that part enough or is there
something else happening in the big/original flow?

If there is then the (req 'key) stuff further down will probably not
work properly, where (req) is:

(de req (Key)
   (get Key 'http))


/Henrik

On Sat, Dec 19, 2009 at 2:17 PM, Alexander Burger <a...@software-lab.de> wro=
te:
> On Sat, Dec 19, 2009 at 10:05:24AM +0100, Alexander Burger wrote:
>> 1. Fork for each transaction:
>>
>> =A0 =A0 =A0 (task (port 4000) =A0# Background task listening on port 400=
0
>> =A0 =A0 =A0 =A0 =A0(when (setq Sock (accept @)) =A0# Accept a connection
>> =A0 =A0 =A0 =A0 =A0 =A0 (unless (fork) =A0# Child process
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(task P)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(close P) =A0# Close port in child proces=
s
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(in Sock
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match ...) =A0# Read payload data
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (ht:Read ...)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (dosomething) )
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(bye) ) =A0# Exit child process
>> =A0 =A0 =A0 =A0 =A0 =A0 (close Sock) ) ) =A0# Close socket in parent pro=
cess
>
> Henrik just pointed out in IRC that 'P' is not bound.
>
> In fact, the two lines
>
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(task P)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(close P) =A0# Close port in child proces=
s
>
> are not really needed here. They are necessary only when the child
> process would last longer, and do some event handling on its own.
>
> So I would use the corrected version:
>
> =A0 =A0 =A0(task (port 4000) =A0# Background task listening on port 4000
> =A0 =A0 =A0 =A0 (let? Sock (accept @) =A0# Accept a connection
> =A0 =A0 =A0 =A0 =A0 =A0(unless (fork) =A0# Child process
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (in Sock
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(match ...) =A0# Read payload data
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(ht:Read ...)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(dosomething) )
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (bye) ) =A0# Exit child process
> =A0 =A0 =A0 =A0 =A0 =A0(close Sock) ) ) =A0# Close socket in parent proce=
ss
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe
>
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to