Ueland / VikingBot

Vikingbot is yet another simple PHP based IRC bot with support for plugins and secure IRC servers. The bot requires Unix/Linux shell access with PHP support and SSL support in PHP for use against secure IRC servers.
GNU General Public License v3.0
40 stars 6 forks source link

Add threaded plugin calls #35

Closed hashworks closed 9 years ago

hashworks commented 9 years ago

That's a big maybe. When multiple users request time intensive commands the bot can get quite slow. Threaded plugin calls could avoid that. But I need to take some time looking into the PHP threaded system, never used it. I think you also need to recompile PHP, so it's kind of optional for the man in the street.

PS: I'll post stuff I'll work on over the next days. Feel free to implement them if you find time.

Ueland commented 9 years ago

I have never experienced the need to recompile PHP in order to get pcntl_fork to work, that being said i have always used default Ubuntu/Debian/Red Hat packages, so i doubt that it would be big issue.

hashworks commented 9 years ago

I'm not talking about process forking but actual threading using pthreads: http://php.net/manual/de/class.thread.php

I would prefer that because of the IPC and zombie problems when using forks.

Ueland commented 9 years ago

Ah, then i understand, and yes, i was a bit worried about the zombie issues myself.

hashworks commented 9 years ago

My approach: VikingBot-Class instance A creates Plugin-Class instance B. A creates Threaded-Class instance C with B as a parameter. A tells C to call B threaded. The problem: As soon as I give B to C, the socket in B turns to int(0).

I'm not absolutely sure what's the cause.

hashworks commented 9 years ago

Seems like sending resources to a pthread is a bad idea.

Any alternative?

Ueland commented 9 years ago

Not that i can think of yet.