View Single Post
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-15-2016 , 08:01   Re: Klippy's Webserver
Reply With Quote #13

Quote:
Originally Posted by PartialCloning View Post
The module is pretty impressive.
Thanks :^)

Quote:
Do you ever plan on completing it? Most of it seems to work from what I've tested.
Probably. I know that POST request processing doesn't work properly (wasn't implemented actually, requires some extra code) and that I have to rework how handles are allocated(free handles are not re-used), not sure if there is anything else.

Quote:
1. It prints "[META] ERROR: Plugin didn't set meta_result: webserver_amxx.dll:ServerActivate()" in the server console.
Forgot to add RETURN_META, fixed. It's strange I haven't noticed that one.

Quote:
2
Code:
WS_QueueResponse(WSConnection: connection, WSStatusCode: status, WSResponse: response);
-->
Code:
WS_QueueResponse(WSConnection: connection, status, WSResponse: response);
I probably wanted to create a WStatusCode enumeration at one point then forgot. I think removing the tag would be wise as someone may want to put a status code other than pre-defined ones.

Quote:
3. Something very strange is how using the same exact code produces an error in one plugin and crashes another.

Code:
#include <amxmodx> #include <webserver> public plugin_init() {     WS_RegisterRequestCallback("home", "OnWebServerHome");     WS_RegisterRequestCallback("motd", "OnWebServerHome"); } public OnWebServerHome(WSConnection:Connection, const Method[], const URL[]) {     static Threshold;     server_print("%d", Threshold++);     new WSResponse:WS_FILERESPONSE = WS_CreateFileResponse("motd.txt");     new WS_RETURN = WS_QueueResponse(Connection, WS_StatusCode_OK, WS_FILERESPONSE);     WS_DestroyResponse(WS_FILERESPONSE);     return WS_RETURN; }

[WEBSERVER] Invalid handle -1
[AMXX] Displaying debug trace (plugin "test.amxx", version "unknown")
[AMXX] Run time error 10: native error (native "WS_QueueResponse")
[AMXX] [0] test.sma::OnWebServerHome (line 17)

When I spam refresh through my web browser I get that error at random points. That function can get called over 100 times without giving out any errors, then it errors out twice within 10 calls. It's random. In another plugin where I have the same exact code among other functions that are not related to webserver, the server crashes rather when I spam refresh, no errors just crashing. Any idea what might be causing this or what kind of tests I can do to try to figure out what's causing this?
Probably this piece of code failed:
PHP Code:
int fd openfd(MF_BuildPathname("%s"path), FDMODE);
if (
fd 0) {
    return -
1;

meaning that it couldn't open the file for reading. Why? I have no idea, but spamming might have to do something with it. I guess you can check if WS_CreateFileResponse() return value is -1 then do something else, maybe display 404.

I attached a new one with the first error fixed. Also, now when the file opening fails it will print the error code in the console - that will help us debug the native.
Attached Files
File Type: dll webserver_amxx.dll (76.5 KB, 93 views)
klippy is offline