|
105 | 105 | 0
|
106 | 106 | (cffi:null-pointer)
|
107 | 107 | 0)))
|
108 |
| - (check-null-p conn) |
| 108 | + (check-null-p conn) |
109 | 109 | (setf quic-conn conn))))
|
110 |
| - (sb-ext:schedule-timer |
111 |
| - (sb-ext:make-timer (lambda () (process-conns client)) :thread t) |
112 |
| - 0.1) |
113 | 110 | client)
|
114 | 111 |
|
115 | 112 | (defmethod new-engine ((client client))
|
|
122 | 119 | (with-slots (engine) client
|
123 | 120 | (engine-destroy engine)))
|
124 | 121 |
|
125 |
| -(defmethod process-conns ((client client)) |
126 |
| - (bt:with-lock-held ((lock client)) |
127 |
| - (with-slots (engine) client |
128 |
| - (lsquic:engine-process-conns engine) |
129 |
| - (with-pointer-to-int (diff 0) |
130 |
| - (when (> (lsquic:engine-earliest-adv-tick engine diff) 0) |
131 |
| - (sb-ext:schedule-timer |
132 |
| - (sb-ext:make-timer (lambda () (process-conns client)) :thread t) |
133 |
| - (/ (mem-aref diff :int) 1000000))))))) |
134 |
| - |
135 | 122 | (defmethod connect ((client client))
|
136 | 123 | (set-context client)
|
137 | 124 | (new-engine client)
|
138 | 125 | (quic-connect client)
|
139 |
| - (process-conns client) |
140 |
| - (packets-in client)) |
141 |
| - |
142 |
| -(defmethod packets-in ((client client)) |
143 |
| - ;; TODO: Switch to libev |
144 |
| - (bt:with-lock-held ((lock client)) |
145 |
| - (with-slots (socket engine peer-ctx) client |
146 |
| - (let ((read (udp:recv-packets-in engine (local-sockaddr socket) (sb-bsd-sockets:socket-file-descriptor (socket socket)) peer-ctx))) |
147 |
| - (when (>= read 0) |
148 |
| - (lsquic:engine-process-conns engine) |
149 |
| - (sb-ext:schedule-timer |
150 |
| - (sb-ext:make-timer (lambda () (packets-in client)) :thread t) |
151 |
| - 0.1)))))) |
| 126 | + (start-new-loop client)) |
152 | 127 |
|
153 | 128 | (defmethod push-stream-ctx ((client client) ctx)
|
154 | 129 | (bt:with-lock-held ((rq-lock client))
|
|
163 | 138 | (push-stream-ctx client pipe)
|
164 | 139 | (conn-make-stream (quic-conn client))
|
165 | 140 | pipe))
|
| 141 | + |
| 142 | +(defmethod get-fd ((client client)) |
| 143 | + (sb-bsd-sockets:socket-file-descriptor (socket (socket client)))) |
| 144 | + |
| 145 | +(defmethod start-new-loop ((client client)) |
| 146 | + (let ((io (cffi:foreign-alloc '(:struct lev:ev-io))) |
| 147 | + (timer (cffi:foreign-alloc '(:struct lev:ev-timer)))) |
| 148 | + (lev:ev-init timer (callback process-conns-cb)) |
| 149 | + (lev:ev-io-init io (callback packets-in-cb) (get-fd client) lev:+ev-read+))) |
0 commit comments