Skip to content

Commit 7f862c2

Browse files
committed
Change sythesised errno from EPROTO to EILSEQ
EILSEQ is mandated by C unlike EPROTO (though EPROTO **is** in C++11). Notably OpenBSD is missing EPROTO
1 parent a80b4e9 commit 7f862c2

File tree

10 files changed

+117
-117
lines changed

10 files changed

+117
-117
lines changed

http/h1_connection.lua

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,20 @@ function connection_methods:read_request_line(timeout)
146146
end
147147
if line == nil then
148148
if err == nil and self.socket:pending() > 0 then
149-
self.socket:seterror("r", ce.EPROTO)
149+
self.socket:seterror("r", ce.EILSEQ)
150150
if preline then
151151
local ok, errno2 = self.socket:unget(preline)
152152
if not ok then
153153
return nil, onerror(self.socket, "unget", errno2)
154154
end
155155
end
156-
return nil, onerror(self.socket, "read_request_line", ce.EPROTO)
156+
return nil, onerror(self.socket, "read_request_line", ce.EILSEQ)
157157
end
158158
return nil, err, errno
159159
end
160160
local method, path, httpversion = line:match("^(%w+) (%S+) HTTP/(1%.[01])\r\n$")
161161
if not method then
162-
self.socket:seterror("r", ce.EPROTO)
162+
self.socket:seterror("r", ce.EILSEQ)
163163
local ok, errno2 = self.socket:unget(line)
164164
if not ok then
165165
return nil, onerror(self.socket, "unget", errno2)
@@ -170,7 +170,7 @@ function connection_methods:read_request_line(timeout)
170170
return nil, onerror(self.socket, "unget", errno2)
171171
end
172172
end
173-
return nil, onerror(self.socket, "read_request_line", ce.EPROTO)
173+
return nil, onerror(self.socket, "read_request_line", ce.EILSEQ)
174174
end
175175
httpversion = httpversion == "1.0" and 1.0 or 1.1 -- Avoid tonumber() due to locale issues
176176
return method, path, httpversion
@@ -180,19 +180,19 @@ function connection_methods:read_status_line(timeout)
180180
local line, err, errno = self.socket:xread("*L", timeout)
181181
if line == nil then
182182
if err == nil and self.socket:pending() > 0 then
183-
self.socket:seterror("r", ce.EPROTO)
184-
return nil, onerror(self.socket, "read_status_line", ce.EPROTO)
183+
self.socket:seterror("r", ce.EILSEQ)
184+
return nil, onerror(self.socket, "read_status_line", ce.EILSEQ)
185185
end
186186
return nil, err, errno
187187
end
188188
local httpversion, status_code, reason_phrase = line:match("^HTTP/(1%.[01]) (%d%d%d) (.*)\r\n$")
189189
if not httpversion then
190-
self.socket:seterror("r", ce.EPROTO)
190+
self.socket:seterror("r", ce.EILSEQ)
191191
local ok, errno2 = self.socket:unget(line)
192192
if not ok then
193193
return nil, onerror(self.socket, "unget", errno2)
194194
end
195-
return nil, onerror(self.socket, "read_status_line", ce.EPROTO)
195+
return nil, onerror(self.socket, "read_status_line", ce.EILSEQ)
196196
end
197197
httpversion = httpversion == "1.0" and 1.0 or 1.1 -- Avoid tonumber() due to locale issues
198198
return httpversion, status_code, reason_phrase
@@ -216,8 +216,8 @@ function connection_methods:read_header(timeout)
216216
end
217217
end
218218
if pending_bytes > 0 then
219-
self.socket:seterror("r", ce.EPROTO)
220-
return nil, onerror(self.socket, "read_header", ce.EPROTO)
219+
self.socket:seterror("r", ce.EILSEQ)
220+
return nil, onerror(self.socket, "read_header", ce.EILSEQ)
221221
end
222222
end
223223
return nil, err, errno
@@ -232,12 +232,12 @@ function connection_methods:read_header(timeout)
232232
message before forwarding the message downstream.]]
233233
local key, val = line:match("^([^%s:]+):[ \t]*(.-)[ \t]*$")
234234
if not key then
235-
self.socket:seterror("r", ce.EPROTO)
235+
self.socket:seterror("r", ce.EILSEQ)
236236
local ok, errno2 = self.socket:unget(line)
237237
if not ok then
238238
return nil, onerror(self.socket, "unget", errno2)
239239
end
240-
return nil, onerror(self.socket, "read_header", ce.EPROTO)
240+
return nil, onerror(self.socket, "read_header", ce.EILSEQ)
241241
end
242242
return key, val
243243
end
@@ -247,14 +247,14 @@ function connection_methods:read_headers_done(timeout)
247247
if crlf == "\r\n" then
248248
return true
249249
elseif crlf ~= nil or (err == nil and self.socket:pending() > 0) then
250-
self.socket:seterror("r", ce.EPROTO)
250+
self.socket:seterror("r", ce.EILSEQ)
251251
if crlf then
252252
local ok, errno2 = self.socket:unget(crlf)
253253
if not ok then
254254
return nil, onerror(self.socket, "unget", errno2)
255255
end
256256
end
257-
return nil, onerror(self.socket, "read_headers_done", ce.EPROTO)
257+
return nil, onerror(self.socket, "read_headers_done", ce.EILSEQ)
258258
else
259259
return nil, err, errno
260260
end
@@ -275,19 +275,19 @@ function connection_methods:read_body_chunk(timeout)
275275
local chunk_header, err, errno = self.socket:xread("*L", timeout)
276276
if chunk_header == nil then
277277
if err == nil and self.socket:pending() > 0 then
278-
self.socket:seterror("r", ce.EPROTO)
279-
return nil, onerror(self.socket, "read_body_chunk", ce.EPROTO)
278+
self.socket:seterror("r", ce.EILSEQ)
279+
return nil, onerror(self.socket, "read_body_chunk", ce.EILSEQ)
280280
end
281281
return nil, err, errno
282282
end
283283
local chunk_size, chunk_ext = chunk_header:match("^(%x+) *(.-)\r\n")
284284
if chunk_size == nil then
285-
self.socket:seterror("r", ce.EPROTO)
285+
self.socket:seterror("r", ce.EILSEQ)
286286
local unget_ok1, unget_errno1 = self.socket:unget(chunk_header)
287287
if not unget_ok1 then
288288
return nil, onerror(self.socket, "unget", unget_errno1)
289289
end
290-
return nil, onerror(self.socket, "read_body_chunk", ce.EPROTO)
290+
return nil, onerror(self.socket, "read_body_chunk", ce.EILSEQ)
291291
elseif #chunk_size > 8 then
292292
self.socket:seterror("r", ce.E2BIG)
293293
return nil, onerror(self.socket, "read_body_chunk", ce.E2BIG)
@@ -312,7 +312,7 @@ function connection_methods:read_body_chunk(timeout)
312312
local chunk_data = assert(self.socket:xread(chunk_size, "b", 0))
313313
local crlf = assert(self.socket:xread(2, "b", 0))
314314
if crlf ~= "\r\n" then
315-
self.socket:seterror("r", ce.EPROTO)
315+
self.socket:seterror("r", ce.EILSEQ)
316316
local unget_ok3, unget_errno3 = self.socket:unget(crlf)
317317
if not unget_ok3 then
318318
return nil, onerror(self.socket, "unget", unget_errno3)
@@ -325,7 +325,7 @@ function connection_methods:read_body_chunk(timeout)
325325
if not unget_ok1 then
326326
return nil, onerror(self.socket, "unget", unget_errno1)
327327
end
328-
return nil, onerror(self.socket, "read_body_chunk", ce.EPROTO)
328+
return nil, onerror(self.socket, "read_body_chunk", ce.EILSEQ)
329329
end
330330
-- Success!
331331
return chunk_data, chunk_ext

http/h1_stream.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function stream_methods:shutdown()
169169
if not self.body_write_type then
170170
-- Can send an automatic error response
171171
local error_headers
172-
if self.connection:error("r") == ce.EPROTO then
172+
if self.connection:error("r") == ce.EILSEQ then
173173
error_headers = bad_request_headers
174174
else
175175
error_headers = server_error_headers

http/h2_connection.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ end
185185

186186
local function handle_frame(self, typ, flag, streamid, payload, deadline)
187187
if self.need_continuation and (typ ~= 0x9 or self.need_continuation.id ~= streamid) then
188-
return nil, h2_error.errors.PROTOCOL_ERROR:new_traceback("CONTINUATION frame expected"), ce.EPROTO
188+
return nil, h2_error.errors.PROTOCOL_ERROR:new_traceback("CONTINUATION frame expected"), ce.EILSEQ
189189
end
190190
local handler = h2_stream.frame_handlers[typ]
191191
-- http2 spec section 4.1:
@@ -194,7 +194,7 @@ local function handle_frame(self, typ, flag, streamid, payload, deadline)
194194
local stream = self.streams[streamid]
195195
if stream == nil and (not self.recv_goaway_lowest or streamid < self.recv_goaway_lowest) then
196196
if xor(streamid % 2 == 1, self.type == "client") then
197-
return nil, h2_error.errors.PROTOCOL_ERROR:new_traceback("Streams initiated by a client MUST use odd-numbered stream identifiers; those initiated by the server MUST use even-numbered stream identifiers"), ce.EPROTO
197+
return nil, h2_error.errors.PROTOCOL_ERROR:new_traceback("Streams initiated by a client MUST use odd-numbered stream identifiers; those initiated by the server MUST use even-numbered stream identifiers"), ce.EILSEQ
198198
end
199199
-- TODO: check MAX_CONCURRENT_STREAMS
200200
stream = self:new_stream(streamid)
@@ -227,7 +227,7 @@ function connection_methods:step(timeout)
227227
return nil, err, errno
228228
end
229229
if not ok then
230-
return nil, h2_error.errors.PROTOCOL_ERROR:new_traceback("invalid connection preface. not an http2 client?"), ce.EPROTO
230+
return nil, h2_error.errors.PROTOCOL_ERROR:new_traceback("invalid connection preface. not an http2 client?"), ce.EILSEQ
231231
end
232232
self.has_confirmed_preface = true
233233
end
@@ -238,7 +238,7 @@ function connection_methods:step(timeout)
238238
-- flag might be `nil` on EOF
239239
ok, connection_error, errno = nil, flag, streamid
240240
elseif not self.has_first_settings and typ ~= 0x4 then -- XXX: Should this be more strict? e.g. what if it's an ACK?
241-
ok, connection_error, errno = false, h2_error.errors.PROTOCOL_ERROR:new_traceback("A SETTINGS frame MUST be the first frame sent in an HTTP/2 connection"), ce.EPROTO
241+
ok, connection_error, errno = false, h2_error.errors.PROTOCOL_ERROR:new_traceback("A SETTINGS frame MUST be the first frame sent in an HTTP/2 connection"), ce.EILSEQ
242242
else
243243
ok, connection_error, errno = handle_frame(self, typ, flag, streamid, payload, deadline)
244244
if ok then
@@ -258,7 +258,7 @@ function connection_methods:step(timeout)
258258
self:write_goaway_frame(nil, code, message, deadline and deadline-monotime())
259259
end
260260
if errno == nil and h2_error.is(connection_error) and connection_error.code == h2_error.errors.PROTOCOL_ERROR.code then
261-
errno = ce.EPROTO
261+
errno = ce.EILSEQ
262262
end
263263
return nil, connection_error, errno
264264
end
@@ -376,8 +376,8 @@ function connection_methods:read_http2_frame(timeout)
376376
return nil, err, errno
377377
elseif err == nil then
378378
if self.socket:pending() > 0 then
379-
self.socket:seterror("r", ce.EPROTO)
380-
return nil, onerror(self.socket, "read_http2_frame", ce.EPROTO)
379+
self.socket:seterror("r", ce.EILSEQ)
380+
return nil, onerror(self.socket, "read_http2_frame", ce.EILSEQ)
381381
end
382382
return nil
383383
else
@@ -407,8 +407,8 @@ function connection_methods:read_http2_frame(timeout)
407407
return nil, onerror(self.socket, "unget", errno3, 2)
408408
end
409409
if err2 == nil then
410-
self.socket:seterror("r", ce.EPROTO)
411-
return nil, onerror(self.socket, "read_http2_frame", ce.EPROTO)
410+
self.socket:seterror("r", ce.EILSEQ)
411+
return nil, onerror(self.socket, "read_http2_frame", ce.EILSEQ)
412412
end
413413
return nil, err2, errno2
414414
end

0 commit comments

Comments
 (0)