Comparison

net/server_epoll.lua @ 10418:c8aa66595072

net.server_epoll: Save log tag in a field on FD watchers too As with 0e1701197722
author Kim Alvefur <zash@zash.se>
date Sun, 17 Nov 2019 23:27:48 +0100
parent 10417:d8a0b0d21c81
child 10419:3b9d17c234df
comparison
equal deleted inserted replaced
10417:d8a0b0d21c81 10418:c8aa66595072
381 self:onconnect(); 381 self:onconnect();
382 self:onincoming(partial, err); 382 self:onincoming(partial, err);
383 end 383 end
384 if err ~= "timeout" then 384 if err ~= "timeout" then
385 self:on("disconnect", err); 385 self:on("disconnect", err);
386 self:destroy() 386 self:close()
387 return; 387 return;
388 end 388 end
389 end 389 end
390 if not self.conn then return; end 390 if not self.conn then return; end
391 if self._limit and (data or partial) then 391 if self._limit and (data or partial) then
800 conn.getfd = function () 800 conn.getfd = function ()
801 return fd; 801 return fd;
802 end; 802 end;
803 -- Otherwise it'll need to be something LuaSocket-compatible 803 -- Otherwise it'll need to be something LuaSocket-compatible
804 end 804 end
805 conn.log = logger.init(("fdwatch%s"):format(new_id())); 805 conn.id = new_id();
806 conn.log = logger.init(("fdwatch%s"):format(conn.id));
806 conn:add(onreadable, onwritable); 807 conn:add(onreadable, onwritable);
807 return conn; 808 return conn;
808 end; 809 end;
809 810
810 -- Dump all data from one connection into another 811 -- Dump all data from one connection into another
909 close = function (self) 910 close = function (self)
910 self:del(); 911 self:del();
911 fds[fd] = nil; 912 fds[fd] = nil;
912 end; 913 end;
913 }, interface_mt); 914 }, interface_mt);
914 conn.log = logger.init(("fdwatch%d"):format(conn:getfd())); 915 conn.id = conn:getfd();
916 conn.log = logger.init(("fdwatch%d"):format(conn.id));
915 local ok, err = conn:add(mode == "r" or mode == "rw", mode == "w" or mode == "rw"); 917 local ok, err = conn:add(mode == "r" or mode == "rw", mode == "w" or mode == "rw");
916 if not ok then return ok, err; end 918 if not ok then return ok, err; end
917 return conn; 919 return conn;
918 end; 920 end;
919 }; 921 };