Megatest

Diff
Login

Differences From Artifact [6c61845b3c]:

To Artifact [9720e8582c]:


786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803











804
805

806
807
808
809
810
811
812





813
814



815
816
817
818
819
820
821
786
787
788
789
790
791
792











793
794
795
796
797
798
799
800
801
802
803
804

805
806
807





808
809
810
811
812


813
814
815
816
817
818
819
820
821
822







-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+

-
+


-
-
-
-
-
+
+
+
+
+
-
-
+
+
+







	 (handler  (tt-handler ttdat)) ;; the handler comes from our client setting a handler function
	 (handler-proc (lambda ()
			 (let* ((indat         (deserialize))
				(result        #f)
				(exn-result    #f)
				(stdout-result (with-output-to-string
						 (lambda ()
						   (let ((res (handle-exceptions
								  exn
								(let* ((errdat (condition->list exn)))
								  (set! exn-result errdat)
								  (debug:print 0 *default-log-port* "ERROR: handler exception, these are bad, will exit in five seconds.")
								  (pp errdat *default-log-port*)
								  ;; these are always bad, set up an exit thread
								  (thread-start! (make-thread (lambda ()
												(thread-sleep! 5)
												(exit))))
								  #f)
						   (let ((res ;; ndle-exceptions
							      ;;  exn
							      ;; let* ((errdat (condition->list exn)))
							      ;;  (set! exn-result errdat)
							      ;;  (debug:print 0 *default-log-port* "ERROR: handler exception, these are bad, will exit in five seconds.")
							      ;;  (pp errdat *default-log-port*)
							      ;;  ;; these are always bad, set up an exit thread
							      ;;  (thread-start! (make-thread (lambda ()
							      ;; 				(thread-sleep! 5)
							      ;; 				(exit))))
							      ;;  #f)
								(handler indat) ;; this is the proc being called by the remote client
								)))
								)) ;; )
						     (set! result res)))))
				(full-result (list result exn-result (if (equal? stdout-result "") #f stdout-result))))
			   (handle-exceptions
			       exn
			     (begin
			       (debug:print 0 *default-log-port* "Serialization failure. full-result="full-result)
			       ;; (serialize '(#f #f #f)) ;; doesn't work - the first call to serialize caused failure
			   ;; (handle-exceptions
			   ;;     exn
			   ;;   (begin
			   ;;     (debug:print 0 *default-log-port* "Serialization failure. full-result="full-result)
			   ;;     ;; (serialize '(#f #f #f)) ;; doesn't work - the first call to serialize caused failure
			       )
			     (serialize full-result))))))
			   ;;     
			   ;;     )
			     (serialize full-result))))) ;; )
    ((make-tcp-server socket handler-proc)
     #f ;; yes, send error messages to std-err
     )))

;; create a tcp listener and return a populated udat struct with
;; my port, address, hostname, pid etc.
;; return #f if fail to find a port to allocate.