Comparison

net/server_epoll.lua @ 9931:485231f8b75d 0.11

net.server_epoll: Handle LuaSec wantread/wantwrite conditions before callbacks (fixes #1333) This prevents the :set(true) call from resuming a connection that was paused in the onincoming callback.
author Kim Alvefur <zash@zash.se>
date Thu, 28 Mar 2019 12:31:14 +0100
parent 9822:13c2707d2417
child 9932:df73ca804719
comparison
equal deleted inserted replaced
9881:68faa0c1a99c 9931:485231f8b75d
353 local data, err, partial = self.conn:receive(self.read_size or cfg.read_size); 353 local data, err, partial = self.conn:receive(self.read_size or cfg.read_size);
354 if data then 354 if data then
355 self:onconnect(); 355 self:onconnect();
356 self:on("incoming", data); 356 self:on("incoming", data);
357 else 357 else
358 if err == "wantread" then
359 self:set(true, nil);
360 err = "timeout";
361 elseif err == "wantwrite" then
362 self:set(nil, true);
363 err = "timeout";
364 end
358 if partial and partial ~= "" then 365 if partial and partial ~= "" then
359 self:onconnect(); 366 self:onconnect();
360 self:on("incoming", partial, err); 367 self:on("incoming", partial, err);
361 end 368 end
362 if err == "wantread" then 369 if err ~= "timeout" then
363 self:set(true, nil);
364 elseif err == "wantwrite" then
365 self:set(nil, true);
366 elseif err ~= "timeout" then
367 self:on("disconnect", err); 370 self:on("disconnect", err);
368 self:destroy() 371 self:destroy()
369 return; 372 return;
370 end 373 end
371 end 374 end