🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.perl
Article #51865

połączenie do bazy z kilku wątków

#51865
From: Pasman
Date: Mon, 29 Mar 2010 12:25
39 lines
2219 bytes
cześć.
tworzę prosty serwerek, który wysyła zapytania do bazy w postgresie.
niestety połączenie z procesów potomnych nie funkcjonuje i wypluwa:


DBD::ODBC::db prepare failed: handle 2 is owned by thread 275014 not
current thr
ead 1ed3abc (handles can't be shared between threads and your driver
may need a
CLONE method added) at E:\WWW\menu3.bat line 53.

jak przerobić to żeby działało ?
############################################
my $dbh = DBI->connect("dbi:ODBC:TEST", "postgres", "postgres")
        or do {print "Baza  nieczynna !!! ".$DBI::errstr; return};

$dbh->{LongTruncOk} = 1;     		# use 1 if it is ok to trunc data
$dbh->{LongReadLen} = 8192; 		# 8kB text max


while ($acc = $sock->accept()) {

	unless (fork()) {
		print $acc "HTTP/1.0 200 OK\n\n";
		print $acc "<html>\n";

		my $sth = $dbh->prepare("select * from www(?)");
		$sth->execute('A');

		while (my $ary = $sth->fetchrow_arrayref) {
			print $acc $ary->[0]."\n";
		};

		$sth->finish;
	};

   print $@ if $@;
   close $acc;
};
Technical Details
Message-ID: <da41ec8d-e8eb-4082-84d1-ca63d45e2957@y6g2000yqm.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!y6g2000yqm.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!y6g2000yqm.googlegroups.com!not-for-mail
From: Pasman <pasman.p@gmail.com>
Newsgroups: pl.comp.lang.perl
Subject: połączenie do bazy z kilku
 wątków
Date: Mon, 29 Mar 2010 05:25:02 -0700 (PDT)
Organization: http://groups.google.com
Lines: 39
Message-ID: <da41ec8d-e8eb-4082-84d1-ca63d45e2957@y6g2000yqm.googlegroups.com>
NNTP-Posting-Host: 212.160.172.70
Mime-Version: 1.0
X-Trace: posting.google.com 1269865502 13022 127.0.0.1 (29 Mar 2010 12:25:02 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 29 Mar 2010 12:25:02 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: y6g2000yqm.googlegroups.com; posting-host=212.160.172.70;  posting-account=rPSDZwoAAACL4OFBPtLUb7YvKmF6ATzr
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;  [eburo v2.0]; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152;  .NET CLR 3.5.30729),gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit