Problem with object properties on sock

Mike Gran <[email protected]> Sun, 24 Mar 2013 08:02:56 -0700
Newsgroups gmane.network.serveez.bugs
Message-ID <[email protected]>
--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi.  I'm having a problem keeping object properties on sockets.  The attached
script is intended to implement a counter of the number of times a given
socket is called, but, the counter property that I attach to the socket
isn't preserved between calls to `handle-request'.

Any suggestions?

-Mike


--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bug.scm"

(define (svz:sock:local-host-order-address sock)
  (ntohl (car (svz:sock:local-address sock))))	   
(define (svz:sock:local-host-order-port sock)
  (ntohs (cdr (svz:sock:local-address sock))))	   
(define (svz:sock:remote-host-order-address sock)
  (ntohl (car (svz:sock:remote-address sock))))	   
(define (svz:sock:remote-host-order-port sock)
  (ntohs (cdr (svz:sock:remote-address sock))))

(define :Prop (make-object-property))

(define (%DumpSocket s)
  (let ((remote-address (svz:sock:remote-host-order-address s))
	(remote-port (svz:sock:remote-host-order-port s))
	(local-address (svz:sock:local-host-order-address s))
	(local-port (svz:sock:local-host-order-port s)))
    (format #t "socket ~s~%" s)
    (format #t "- remote address ~s:~s~%"
	    (inet-ntop AF_INET remote-address)
	    remote-port)
    (format #t "- local address ~s:~s~%"
	    (inet-ntop AF_INET local-address)
	    local-port)
    (format #t "- :Prop ~s~%" (:Prop s))))

(define (bug2-handle-request sock binary size)
  (format #t "In bug2-handle-request~%")
  (format #t "BEFORE~%")
  (%DumpSocket sock)
  (if (:Prop sock)
      (set! (:Prop sock) (1+ (:Prop sock)))
      (set! (:Prop sock) 1))
  (format #f "AFTER~%")
  (%DumpSocket sock)
  1)

(define-servertype!
  '((prefix . "bug2")
    (description . "test object properties")
    (handle-request . bug2-handle-request)
    (configuration . ())))

(define-server! 'bug2-server)
(bind-udp-port-range! 1069 1070 'bug2-server)

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
bug-serveez mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-serveez

--OXfL5xGRrasGEqWY--