FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

httpserver + dbi

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
elgato



Joined: 29 Dec 2007
Posts: 20

PostPosted: Fri Feb 08, 2008 12:00 pm    Post subject: httpserver + dbi Reply with quote

Hi, i'm trying to do multithreaded http-server with connections to database, this is what i get:

Code:
Code:

import  tango.core.Thread;

import  tango.net.http.HttpConst;

import  tango.util.log.Configurator;

import  mango.net.http.server.HttpServer,
        mango.net.http.server.HttpRequest,
        mango.net.http.server.HttpResponse,
        mango.net.http.server.HttpProvider;

import dbi.mysql.all;
import dbi.Row;

void main ()
{
        // our simple http hander
        class Provider : HttpProvider
        {
                override void service (HttpRequest request, HttpResponse response)
                {
         MysqlDatabase db = new MysqlDatabase();
             db.connect("dbname=mysql;host=localhost;port=3306","root","");
             db.close();
         response.sendError (HttpResponses.OK);
                }
        }
   
   
        // bind server to port 8080 on a local address
        auto addr = new InternetAddress (4666);

        // create a (1 thread) server using the ServiceProvider to service requests
        auto server = new HttpServer (new Provider(), addr, 100, 100);

        // start listening for requests (but this thread does not listen)
        server.start;
}



Doing ab -c 100 -n 100 'http://localhost:4666/' goes ok, but making -c 100 -n 1000 and even -c 5 -n 1000 throws a segfault Sad

Code:
[root@localhost test]# ./httpserver
Attempting to register MysqlDatabase in Registry
10 Info  http.server - Server http::raw started on 0.0.0.0:4666 with 100 accept threads and 100 backlogs
Segmentation fault


Does anyone know how to make correct multithreaded http server with db connections?
Back to top
View user's profile Send private message
elgato



Joined: 29 Dec 2007
Posts: 20

PostPosted: Tue Feb 12, 2008 4:09 am    Post subject: Reply with quote

nobody tried to make http multithread listener with dbi connections? Sad
can't figure it out... it seems that only one object of dbi is used per process, so http listener use the only connection...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group