Cuberite Forum
plugin induced server hang - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: plugin induced server hang (/thread-224.html)



plugin induced server hang - rs2k - 11-11-2011

The lua script I wrote for McBans works, the problem is if mcbans happens to be down then the server will hang until the lua script is done trying to fetch the url.

Any ideas on how to resolve this?


RE: plugin induced server hang - ThuGie - 11-11-2011

your using wget right set -T seconds
like -T 1 its the timeout so it will timeout after 1 sec of trying.

Edit:
http://www.gnu.org/software/wget/manual/html_node/Download-Options.html

if the full timeout gives trouble with reading you might just wanna use
--connect-timeout=seconds for just the connection timeout Smile.


RE: plugin induced server hang - rs2k - 11-11-2011

thanks, but I don't like the idea of a busy server hanging up to one second at a time every time someone logs in or DCs. It's better than a 20 second hang though. lol


RE: plugin induced server hang - FakeTruth - 11-11-2011

Use cTCPLink. Can't explain how it works right nowTongue Try to figure it out


RE: plugin induced server hang - rs2k - 11-11-2011

haha, thanks, I'll look into it.


RE: plugin induced server hang - rs2k - 11-13-2011

I can get this to return true,

Lua__cTCPLink():Connect( "omencraft.com", 80 )

, but that's all I've been able to figure out so far. Any more hints you can give? It seems like once a port is open I need some kind of hook for the plugin to pickup on to send data, and another one to receive data, there aren't any hooks like that in cPluginManager.cpp though.


This always returns a nil value:
Lua__cTCPLink():ReceivedData( data, size )

abd using that as a function in the lua causes a c stack overflow:

function Lua__cTCPLink():ReceivedData( data, size )
print("hello world")
end


RE: plugin induced server hang - FakeTruth - 11-13-2011

Like the plugin, create a new instance of it in Lua

Code:
MyTCPLink = {}
MyTCPLink.__index = MyTCPLink

function MyTCPLink:new()
   local t = {}
   setmetatable(t, CorePlugin)
   local w = Lua__cTCPLink:new()
   tolua.setpeer(w, t)
   w:tolua__set_instance(w)
   return w
end

Then implement the ReceivedData function
Code:
function MyTCPLink:ReceivedData( data, size )
    print("hello world")
end

And create the instance

Code:
Link = MyTCPLink:new()

It's not perfect, so I think it needs workTongue but it should work for really basic things