From: [EMAIL PROTECTED] on behalf of Anderson, Mark (Service Delivery)
Sent: Mon 3/7/2005 1:38 AM
To: perl-win32-admin@listserv.ActiveState.com
Cc: 'Paul Sobey'
Subject: RE: Win32::Daemon and threads
thanks, Paul
I did actually try passing a subroutine
reference - it made no difference at
all. Due to MAPI issues you need
to import the OLE module immediately and
call
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE) from a
BEGIN
block!
I tried starting the threads in various places but it
didn't seem to make
any difference. It seemed to work from interactively (not
using
Win32::Daemon). I've decided that the execution time is small
enough that I
don't need to thread it now anyway but I'm thankful for the
clarification
that there are oddities with OLE, Win32::Daemon and
threads!
Kind regards,
Mark Anderson
Service Improvement
Project
Level 2, 113 Dundas Street
Edinburgh, EH3 5DE
Tel: 0131 523
8786
Mob: 07808 826 063
> -----Original Message-----
>
From: Paul Sobey [SMTP:[EMAIL PROTECTED]
> Sent: Monday, March 07, 2005
9:33 AM
> To: Anderson, Mark (Service Delivery);
>
perl-win32-admin@listserv.ActiveState.com
>
Subject: RE: Win32::Daemon and
threads
>
> *** WARNING : This message originates from the Internet
***
>
> Hi,
>
> When you create the thread, pass in a
reference - from the looks of
> things you are actually running the sub
and passing in its return value
> as a coderef to the threads call. If you
use task manager, does it show
> the thread count of your process going
up? Try this:
>
> $inboxThread = threads->new(\&scanInbox);
#line 155
>
> Two other observations that may help:
>
>
1) Spawn the threads as early as possible, certainly before you do any
>
service interaction. Use queues/semaphores to control the threads, fire
>
them off, then go through the service initialisation bits. Spawning
>
threads after Win32::Daemon::StartService(); is called lead to all sorts
>
of random errors when I was experimenting.
>
> 2) Also, assuming you
are using Win32::OLE to drive MAPI, it's not
> threadsafe, so make sure
you require() the module in one thread, after
> that thread has been
spawned. If you use Win32::OLE at the top of the
> script you'll get all
sorts of hard to trace errors.
>
> Good luck!
>
Paul
>
>
> -----Original Message-----
> From:
[EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
On Behalf Of
> Anderson, Mark (Service Delivery)
> Sent: 07 March
2005 08:28
> To: perl-win32-admin@listserv.ActiveState.com
>
Subject: Win32::Daemon and threads
>
> Hi,
>
> I'm
writing a service to monitor two folders of a mailbox and update a
>
database according to the content of some properties of the
emails.
>
> I've got all the MAPI and ODBC elements working and it
now runs as a
> service
> using Win32::Daemon. I decided to
"use threads" and create two new
> threads
> - one for each folder I
want to monitor. Only one thread does anything
> though even
though I call sleep(10); and even threads->yield().
>
> It
happens even if I only spawn one thread - the mail control loop which
>
checks the service state just stops at the line where I spawn the thread
>
> $inboxThread =
threads->create(&scanInbox); #line 155
>
> The thread behaves
exactly as expected except the whole program does a
> sleep(10) rather
than giving the parent thread CPU time... consequently
> it
>
doesn't respond to server manager. When I put some service state
>
checking
> into the child thread it responds but then crashes when it gets
back to
>
> $inboxThread =
threads->create(&scanInbox);
> I get the error:
> Usage:
threads::new(classname, function_to_call, ...) at MailMonitor.pl
>
line
> 155. in my debug logs (which isn't even documented syntax and it
worked
> first time through).
>
> Am I missing something
fundamental about Windows Services (in perl)? Can
> they only have one
thread (if you use Win32::Daemon)?
>
> any nuggets of wisdom
greatly appreciated!
>
>
>
*****************************************************************
>
Gloucester Research Limited believes the information
> provided herein is
reliable. While every care has been
> taken to ensure accuracy, the
information is furnished
> to the recipients with no warranty as to the
completeness
> and accuracy of its contents and on condition that
any
> errors or omissions shall not be made the basis for any
>
claim, demand or cause for action.
>
*****************************************************************
The
Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered Office:
36 St Andrew Square, Edinburgh EH2 2YB
The Royal Bank of Scotland plc is
authorised and regulated by the Financial Services Authority and represents The
Royal Bank of Scotland Marketing Group. The Bank sells life policies, collective
investment schemes and pension products and advises only on the Marketing
Group's range of these products and on a With-Profit Bond produced by Norwich
Union Life (RBS) Limited.
This e-mail message is confidential and for use
by the addressee only. If the message is received by anyone other than the
addressee, please return the message to the sender by replying to it and then
delete the message from your computer. Internet e-mails are not necessarily
secure. The Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.
Whilst all reasonable
care has been taken to avoid the transmission of viruses, it is the
responsibility of the recipient to ensure that the onward transmission, opening
or use of this message and any attachments will not adversely affect its systems
or data. No responsibility is accepted by The Royal Bank of Scotland plc in this
regard and the recipient should carry out such virus and other checks as it
considers
appropriate.
_______________________________________________
Perl-Win32-Admin
mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________ Perl-Win32-Admin mailing list Perl-Win32-Admin@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs