Hi,

Thank you all for the info.

I have finished writting the handler this morning, and have enabled
Apache::DBI in httpd.conf.
My handler is for this url:
http://bizstatus.game.yy.com/upload/

It accept client's uploaded data and write the data to database.
The strange stuff is, when I run more than one process for test, the
items number in database in not correct.

for example:

ab -n 100 -c 1 http://bizstatus.game.yy.com/upload/?arguments

This insert 100 items into database, the select result is correct.

But this one:

ab -n 100 -c 2 http://bizstatus.game.yy.com/upload/?arguments

or:

ab -n 100 -c 3 http://bizstatus.game.yy.com/upload/?arguments


When the client number is larger than one, the items number in
database is not correct.
it's always larger than 100, for example, 101, 102, 103 etc.

So, what's wrong with my program?

The handler looks as:

package ABC;
use strict;
use Apache2::RequestIO ();
use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::RequestUtil ();
use Apache2::Request ();
use DBI;


use Apache2::Const -compile => qw(OK NOT_FOUND);

sub handler {

    my $r = shift;
    my $q = Apache2::Request->new($r);
    my $ip = $r->connection->remote_ip;

    my $v1 = $q->param('arg1');
    my $v2 = $q->param('arg2');


    my $db = 'mydb';
    my $host = '127.0.0.1';
    my $port = 3306;
    my $user = '***';
    my $passwd = '***';
    my $dbh = DBI->connect("dbi:mysql:database=$db;host=$host;port=$port",
$user, $passwd)
                           or die $DBI::errstr;

    my $str = "insert into mytable (v1,v2,check_time)
               values(?,?,now())";

    my $sth = $dbh->prepare($str);
    $sth->execute($v1,$v2) or die $dbh->errstr;
    $sth->finish;

    $r->content_type('text/plain');
    $r->print('OK');

    return Apache2::Const::OK;
}

1;



Thank you!

Reply via email to