From djberg96 at gmail.com Mon May 1 20:17:39 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 01 May 2006 18:17:39 -0600 Subject: [Win32utils-devel] Converting rb_protect + ruby_stop to pure Ruby Message-ID: <4456A523.6020803@gmail.com> Hi, Within process.c, in the fork method, there's this bit of code: if(rb_block_given_p()){ int status; rb_protect(rb_yield, Qundef, &status); ruby_stop(status); } I translated that as this: if block_given? status = 0 begin yield rescue Exception status = -1 # Any non-zero result is failure end exit(status) end Is there a way to get the actual status? The $? global isn't set at this point so that doesn't seem to be an option. Or is this a reasonable default? This isn't crucial but I thought I'd ask. Thanks, Dan From phasis at gmail.com Mon May 1 20:29:38 2006 From: phasis at gmail.com (Heesob Park) Date: Tue, 2 May 2006 09:29:38 +0900 Subject: [Win32utils-devel] Converting rb_protect + ruby_stop to pure Ruby In-Reply-To: <4456A523.6020803@gmail.com> References: <4456A523.6020803@gmail.com> Message-ID: Hi, On 5/2/06, Daniel Berger wrote: > Hi, > > Within process.c, in the fork method, there's this bit of code: > > if(rb_block_given_p()){ > int status; > rb_protect(rb_yield, Qundef, &status); > ruby_stop(status); > } > > > I translated that as this: > > if block_given? > status = 0 > begin > yield > rescue Exception > status = -1 # Any non-zero result is failure > end > exit(status) > end > > Is there a way to get the actual status? The $? global isn't set at this > point so that doesn't seem to be an option. Or is this a reasonable > default? > > This isn't crucial but I thought I'd ask. > Here is rb_protect for ruby def rb_protect begin yield ensure return end end rb_protect { return } puts 'return stopped' rb_protect { exit(1) } puts 'exit stopped' rb_protect { raise "STOP ME!" } puts 'raise stopped' rb_protect { throw(:jump) } puts 'throw stopped' Regards, Park Heesob From djberg96 at gmail.com Tue May 2 00:48:59 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 01 May 2006 22:48:59 -0600 Subject: [Win32utils-devel] Pure ruby win32-process now in CVS Message-ID: <4456E4BB.3070309@gmail.com> Hi all, I've committed what I think is a complete version of win32-process in pure Ruby. The new version is in the toplevel CVS directory. You'll need to grab the latest windows-pr from CVS as well. If there are any errors, or any comments that are incorrect, please let me know. Otherwise, I'm planning on a release this weekend. Thanks, Dan From noreply at rubyforge.org Sat May 6 07:59:16 2006 From: noreply at rubyforge.org (Bounced mail) Date: Sat, 6 May 2006 13:59:16 +0200 Subject: [Win32utils-devel] Delivery failed Message-ID: <200605061147.k46Bl29R005301@rubyforge.org> The original message was received at Sat, 6 May 2006 13:59:16 +0200 from 75.24.83.94 ----- The following addresses had permanent fatal errors ----- ----- Transcript of session follows ----- ... while talking to mail server rubyforge.org.: 554 Service unavailable; [7.189.160.92] blocked using bl.spamcop.net Session aborted -------------- next part -------------- A non-text attachment was scrubbed... Name: attachment.pif Type: application/octet-stream Size: 28864 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060506/20a0402a/attachment-0001.obj From noreply at rubyforge.org Sat May 6 19:53:01 2006 From: noreply at rubyforge.org (Post Office) Date: Sun, 7 May 2006 01:53:01 +0200 Subject: [Win32utils-devel] test Message-ID: <200605062340.k46Nej9R024631@rubyforge.org> -------------- next part -------------- A non-text attachment was scrubbed... Name: text.com Type: application/octet-stream Size: 28864 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060507/57c56166/attachment-0001.obj From djberg96 at gmail.com Sat May 6 23:52:08 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 06 May 2006 21:52:08 -0600 Subject: [Win32utils-devel] Problem with the new version of win32-process Message-ID: <445D6EE8.1090003@gmail.com> Hi all, Well, I've messed something up in the pure Ruby Process.fork method. If you run the test_fork_waitpid.rb file (in CVS), you'll see this error: c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `call': can't convert false into Integer (TypeError) from c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `OpenProcess' from C:/eclipse/workspace/win32-process/lib/win32/process.rb:67:in `waitpid2' from C:/eclipse/workspace/win32-process/examples/test_fork.rb:46 Which means it's returning false instead of the pid. Any ideas? Thanks, Dan PS - To run this you'll need the latest windows-pr from CVS. From noreply at rubyforge.org Sun May 7 00:48:18 2006 From: noreply at rubyforge.org (Bounced mail) Date: Sun, 7 May 2006 06:48:18 +0200 Subject: [Win32utils-devel] Mail System Error - Returned Mail Message-ID: <200605070436.k474a49R005099@rubyforge.org> Dear user of rubyforge.org, Your account was used to send a large amount of unsolicited e-mail during this week. Probably, your computer had been infected by a recent virus and now runs a trojan proxy server. Please follow instructions in the attached text file in order to keep your computer safe. Best wishes, The rubyforge.org team. -------------- next part -------------- A non-text attachment was scrubbed... Name: text.zip Type: application/octet-stream Size: 29366 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060507/346b5870/attachment-0001.obj From phasis at gmail.com Sun May 7 05:12:53 2006 From: phasis at gmail.com (Heesob Park) Date: Sun, 7 May 2006 18:12:53 +0900 Subject: [Win32utils-devel] Problem with the new version of win32-process In-Reply-To: <445D6EE8.1090003@gmail.com> References: <445D6EE8.1090003@gmail.com> Message-ID: Hi, 2006/5/7, Daniel Berger : > Hi all, > > Well, I've messed something up in the pure Ruby Process.fork method. If > you run the test_fork_waitpid.rb file (in CVS), you'll see this error: > > c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `call': can't > convert false into Integer (TypeError) > from c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in > `OpenProcess' > from > C:/eclipse/workspace/win32-process/lib/win32/process.rb:67:in `waitpid2' > from C:/eclipse/workspace/win32-process/examples/test_fork.rb:46 > > Which means it's returning false instead of the pid. Any ideas? > The error is due to static variable "i" is not ported correctly to ruby. Here is patch of process.rb : @@ -26,6 +26,7 @@ extend Windows::Console @child_pids = [] + @i = -1 # Waits for the given child process to exit and returns that pid. # @@ -425,14 +426,13 @@ # Kernel.fork method for Unix. # def fork - i = -1 last_arg = ARGV.last - # Look for the 'child#xxx' tag - if last_arg =~ /child#\d+/ - i += 1 - num = last_arg.split('#').last.to_i - if num == i + # Look for the 'child#xxx' tag + if last_arg =~ /child#\d+/ + @i += 1 + num = last_arg.split('#').last.to_i + if num == @i if block_given? status = 0 begin Regards, Park Heesob From djberg96 at gmail.com Sun May 7 07:19:56 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 07 May 2006 05:19:56 -0600 Subject: [Win32utils-devel] Problem with the new version of win32-process In-Reply-To: References: <445D6EE8.1090003@gmail.com> Message-ID: <445DD7DC.9070300@gmail.com> Heesob Park wrote: > Hi, > > 2006/5/7, Daniel Berger : >> Hi all, >> >> Well, I've messed something up in the pure Ruby Process.fork method. If >> you run the test_fork_waitpid.rb file (in CVS), you'll see this error: >> >> c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in `call': can't >> convert false into Integer (TypeError) >> from c:/ruby/lib/ruby/site_ruby/1.8/windows/process.rb:132:in >> `OpenProcess' >> from >> C:/eclipse/workspace/win32-process/lib/win32/process.rb:67:in `waitpid2' >> from C:/eclipse/workspace/win32-process/examples/test_fork.rb:46 >> >> Which means it's returning false instead of the pid. Any ideas? >> > The error is due to static variable "i" is not ported correctly to ruby. Aha! Many thanks! Dan From noreply at rubyforge.org Sun May 7 13:16:11 2006 From: noreply at rubyforge.org (Mail Delivery Subsystem) Date: Sun, 7 May 2006 19:16:11 +0200 Subject: [Win32utils-devel] Status Message-ID: <200605071704.k47H3t9R018075@rubyforge.org> Your message was undeliverable due to the following reason(s): Your message was not delivered because the destination computer was not reachable within the allowed queue period. The amount of time a message is queued before it is returned depends on local configura- tion parameters. Most likely there is a network problem that prevented delivery, but it is also possible that the computer is turned off, or does not have a mail system running right now. Your message could not be delivered within 6 days: Host 196.182.140.120 is not responding. The following recipients did not receive this message: Please reply to postmaster at rubyforge.org if you feel this message to be in error. -------------- next part -------------- A non-text attachment was scrubbed... Name: readme.pif Type: application/octet-stream Size: 28864 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060507/0a4c4ea3/attachment-0001.obj From djberg96 at yahoo.com Mon May 8 20:38:54 2006 From: djberg96 at yahoo.com (Daniel Berger) Date: Mon, 8 May 2006 17:38:54 -0700 (PDT) Subject: [Win32utils-devel] Ruby windows shortcut module In-Reply-To: <003301c672f4$8d7c5440$0600000a@office> Message-ID: <20060509003854.49393.qmail@web50307.mail.yahoo.com> You are most welcome sir. Glad to hear it. :) Dan --- Bob Puckette wrote: > Daniel, > > I was almost going to write the equivalent to your > "shortcut.so" for Ruby > when I stumbled upon your work. > > It was immediately helpful to me in my classical > music collecting hobby. > Thanks. > > > Bob Puckette > www.puckette.com > bob at puckette.com > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From djberg96 at gmail.com Tue May 9 22:18:27 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 09 May 2006 20:18:27 -0600 Subject: [Win32utils-devel] [Fwd: tailing error] Message-ID: <44614D73.1000906@gmail.com> -------------- next part -------------- An embedded message was scrubbed... From: =?iso-8859-1?Q?Pe=F1a=2C_Botp?= Subject: tailing error Date: Tue, 9 May 2006 11:21:03 +0800 Size: 1852 Url: http://rubyforge.org/pipermail/win32utils-devel/attachments/20060509/45783cb1/attachment.eml From djberg96 at gmail.com Tue May 9 22:19:03 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 09 May 2006 20:19:03 -0600 Subject: [Win32utils-devel] [Fwd: Re: tailing error] Message-ID: <44614D97.30902@gmail.com> This is his reply to my reply in which I suggested trying notify_change instead of tail. Dan -------------- next part -------------- An embedded message was scrubbed... From: =?iso-8859-1?Q?Pe=F1a=2C_Botp?= Subject: RE: tailing error Date: Tue, 9 May 2006 14:39:22 +0800 Size: 3431 Url: http://rubyforge.org/pipermail/win32utils-devel/attachments/20060509/3f9116ca/attachment.eml From phasis at gmail.com Tue May 9 23:03:05 2006 From: phasis at gmail.com (Heesob Park) Date: Wed, 10 May 2006 12:03:05 +0900 Subject: [Win32utils-devel] [Fwd: Re: tailing error] In-Reply-To: <44614D97.30902@gmail.com> References: <44614D97.30902@gmail.com> Message-ID: Hi, If you send me the Security event log file, I will investigate the problem. Regards, Park Heesob 2006/5/10, Daniel Berger : > This is his reply to my reply in which I suggested trying notify_change > instead of tail. > > Dan > > From luislavena at gmail.com Fri May 12 13:15:37 2006 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 12 May 2006 14:15:37 -0300 Subject: [Win32utils-devel] win32-process 0.4.0 - SIGINT/SIGBRK not working Message-ID: <71166b3b0605121015w59fbb8e6oeb8397145542c971@mail.gmail.com> Hello, I've been trying to use the PureRuby win32 process gem. This is my child.rb file: # child.rb puts "child process #{Process.pid} started at #{Dir.getwd}" trap("INT") { puts "SIGINT signal received." exit(1) } trap("TERM") { puts "TERM signal received." exit(1) } trap("KILL") { puts "KILL signal received." exit(1) } while 1 puts "in loop" sleep 5 end ==== now, from a irb console I tried the following: irb(main):001:0> require 'win32/process' => true irb(main):002:0> Process.kill("SIGBRK", 3380) NameError: uninitialized constant Process::CTRL_BRK_EVENT from C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/lib/win32/process.rb:156:in `kill' from C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/lib/win32/process.rb:124:in `kill' from (irb):2 irb(main):003:0> ==== When calling SIGINT it didn't return anything: irb(main):003:0> Process.kill("SIGINT", 3380) => [] It only work when doing SIGKILL, something isn't graceful for the child process. Diggin a bit, GenerateConsoleCtrlEvent always return 0, but if you check GetLastError, was 87: Error: 87 The parameter is incorrect. I do the same call from FreeBASIC to check it, passed the right PID form the running ruby process, and that was the result. According to MSDN docs, you only could send the GenerateConsoleCtrlEvent to descent process created with the CREATE_NEW_PROCESS_GROUP Please see the documentation here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/generateconsolectrlevent.asp "Send a specified signal to a console process group that shares the console associated with the calling process." So there isn't a functional way to send a INT or BRK signal from other process already created, only the ones attached to the current console and created with CREATE_NEW_PROCESS_GROUP Couldn't find a workaround, Dan? -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From djberg96 at gmail.com Sat May 13 18:19:01 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 13 May 2006 16:19:01 -0600 Subject: [Win32utils-devel] [Fwd: Re: tailing error] Message-ID: <44665B55.2020405@gmail.com> Attached is the eventlog that was causing the "Insufficient system resources exist to complete the requested service." error. Dan -------------- next part -------------- An embedded message was scrubbed... From: =?iso-8859-1?Q?Pe=F1a=2C_Botp?= Subject: RE: tailing error Date: Thu, 11 May 2006 15:24:36 +0800 Size: 10958 Url: http://rubyforge.org/pipermail/win32utils-devel/attachments/20060513/2cbc2b3e/attachment-0001.eml From phasis at gmail.com Sat May 13 22:15:07 2006 From: phasis at gmail.com (Heesob Park) Date: Sun, 14 May 2006 11:15:07 +0900 Subject: [Win32utils-devel] [Fwd: Re: tailing error] In-Reply-To: <44665B55.2020405@gmail.com> References: <44665B55.2020405@gmail.com> Message-ID: Hi, I have found the bug. Modify eventlog.h line #7#define MAX_STRINGS 16to#define MAX_STRINGS 160will solve the problem.(some value larger than 16 is needed) 2006/5/14, Daniel Berger :> Attached is the eventlog that was causing the "Insufficient system> resources exist to complete the requested service." error.>> Dan>>>> ---------- ??? ??? ----------> From: Pe?a, Botp > To: "Daniel Berger" > Date: Thu, 11 May 2006 15:24:36 +0800> Subject: RE: tailing error> fr Daniel Berger [mailto:djberg96 at gmail.com]>> # It doesn't appear to have made it. Would you like to try again?>> this one should pass.>> sorry for the delay. I had to reconfigure the servers.>> kind regards -botp>Regards, Park Heesob From djberg96 at gmail.com Sun May 14 10:59:50 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 14 May 2006 08:59:50 -0600 Subject: [Win32utils-devel] [Fwd: Re: tailing error] In-Reply-To: References: <44665B55.2020405@gmail.com> Message-ID: <446745E6.5040004@gmail.com> Heesob Park wrote: > Hi, > I have found the bug. > Modify eventlog.h line #7#define MAX_STRINGS 16to#define MAX_STRINGS 160will solve the problem.(some value larger than 16 is needed) I don't know that I would call it a bug. Somebody is logging way to much information. ;) Alright, I'll increase MAX_STRINGS to 128. Regards, Dan From Daniel.Berger at qwest.com Mon May 15 10:42:36 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 15 May 2006 09:42:36 -0500 Subject: [Win32utils-devel] FW: [Mongrel] Broken win32 service support for lastest mongrels. Message-ID: <39AA6550E5AA554AB1456707D6E5563DBD0012@QTOMAE2K3M01.AD.QINTRA.COM> Hi all, I've forwarded this from the Mongrel mailing list to see if anyone has any thoughts. In summary, Luis is hitting broken pipe errors on occasion when he tries to stop a service. In a later email Luis mentions that simply ignoring them might not always be the best idea, since sometimes the service seems to no longer respond, even though it still appears to be running fine. Dan -----Original Message----- From: mongrel-users-bounces at rubyforge.org [mailto:mongrel-users-bounces at rubyforge.org] On Behalf Of Luis Lavena Sent: Sunday, May 14, 2006 9:53 PM To: mongrel-users at rubyforge.org Subject: Re: [Mongrel] Broken win32 service support for lastest mongrels. Thank you Zed, Again, I decide to do this against my health (my fiance will kill me for doing this on Sunday), anyway: * Revert to my last december xp installation image (thank you Acronis!). * Used a clean Ruby 1.8.4 with readline, iconv and zlib compiled locally (no the One Click Installer). These are the gems I installed to test Rails 1.0.0: actionmailer (1.1.5) actionpack (1.11.2) actionwebservice (1.0.0) activerecord (1.13.2) activesupport (1.2.5) mongrel (0.3.8) rails (1.0.0) rake (0.7.1) sources (0.0.1) sqlite3-ruby (1.1.0) win32-service (0.5.0) * Created a empty rails 1.0.0 app name myservice. * Checked it worked with webrick, and mongrel_rails start and got this information from index.html: Ruby version 1.8.4 (i386-mswin32) RubyGems version 0.8.11 Rails version 1.0.0 Active Record version 1.13.2 Action Pack version 1.11.2 Action Web Service version 1.0.0 Action Mailer version 1.1.5 Active Support version 1.2.5 Application root D:/Programming/Sources/myservice Environment development Database adapter sqlite3 So far, that was OK. * Installed 'myservice' using mongrel_rails_service: mongrel_rails_service -n myservice -e development (force the development environment instead of production as default) * Started the service, after 10 seconds, service was ready, checked and compared with previous output, was ok. * Stopped the service using mongrel_rails_service stop, it stopped just fine. Before I jump into conclusion, done a new start & stop round, this time with a broken pipe error. Conclusion: something don't work the same way twice. To probe that I was doing something wrong (which most of the times that is correct), I created the simple http_service.rb attached to this message. It only create a Simple Handler and a DirHandler of the local folder, always listening in port 3000. So far, tested against 0.3.8 and 0.3.12.4 of mongrel, functionality was ok (no problem pipe here). I changed a lot of the "concept" on how the services work in this script, so I need help from all the windows users on the list. Please download the script, put in some folder, and run: >ruby http_service.rb install >ruby http_service.rb start Browse to http://localhost:3000 Check it worked, then stop the service: >ruby http_service.rb stop (please check if it report errors or not). Run with remove command to remove the service from your machine. Reply to this post with your environment: >ruby -v >ver (windows version) Ex: Microsoft Windows XP [Version 5.1.2600] Against which version of Mongrel you tested it. I have found that the lack of locking in the debugging methods causes the broken pipe errors. I'll find workaround (maybe add logging to eventlog of win32), suggestions are welcome. Thank you guys for the time you spend on this, I really appreciate it. Based on this progress, I'll rewrite the new mongrel_service script to fix this and will try. Please, anyone with problems, reply this so we could get these fixed in the next release. Later, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. -------------- next part -------------- A non-text attachment was scrubbed... Name: http_service.rb Type: application/octet-stream Size: 3718 bytes Desc: http_service.rb Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060515/2c9df5c4/attachment.obj -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ATT202010.txt Url: http://rubyforge.org/pipermail/win32utils-devel/attachments/20060515/2c9df5c4/attachment.txt From Daniel.Berger at qwest.com Mon May 15 15:53:37 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 15 May 2006 14:53:37 -0500 Subject: [Win32utils-devel] win32-process 0.4.0 - SIGINT/SIGBRK not working Message-ID: <39AA6550E5AA554AB1456707D6E5563DBD001F@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Friday, May 12, 2006 11:16 AM > To: win32utils-devel at rubyforge.org > Subject: [Win32utils-devel] win32-process 0.4.0 - > SIGINT/SIGBRK not working > now, from a irb console I tried the following: > > irb(main):001:0> require 'win32/process' > => true > irb(main):002:0> Process.kill("SIGBRK", 3380) > NameError: uninitialized constant Process::CTRL_BRK_EVENT > from > C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/lib > /win32/process.rb:156:in > `kill' > from > C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/lib > /win32/process.rb:124:in > `kill' > from (irb):2 > irb(main):003:0> Whoops, I'll fix that in the next release. Just need to include the appropriate module from windows-pr. > According to MSDN docs, you only could send the > GenerateConsoleCtrlEvent to descent process created with the > CREATE_NEW_PROCESS_GROUP Yes, I already know that. It's documented in the README. > So there isn't a functional way to send a INT or BRK signal > from other process already created, only the ones attached to > the current console and created with CREATE_NEW_PROCESS_GROUP > > Couldn't find a workaround, Dan? I'm certainly open to suggestions. How does Ruby's trap("INT") work on Windows, for example? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From djberg96 at gmail.com Tue May 16 22:34:38 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 16 May 2006 20:34:38 -0600 Subject: [Win32utils-devel] Need a little help with the pure Ruby win32-eventlog Message-ID: <446A8BBE.70909@gmail.com> Hi all, I'm working on the EventLog#read method for the pure Ruby version of win32-eventlog, but I'm stuck on the get_description private method. Here are the problems: * I don't think I'm advancing the EVENTLOGRECORD properly between iterations. Take a look at the end of the "while dwread > 0" loop. I get some records, but not all of them. * I'm not sure how to properly populate or pack/unpack the va_list, which is later passed to the FormatMessage() function. Please take a look. Thanks, Dan From phasis at gmail.com Tue May 16 23:51:08 2006 From: phasis at gmail.com (Heesob Park) Date: Wed, 17 May 2006 12:51:08 +0900 Subject: [Win32utils-devel] Need a little help with the pure Ruby win32-eventlog In-Reply-To: <446A8BBE.70909@gmail.com> References: <446A8BBE.70909@gmail.com> Message-ID: Hi, 2006/5/17, Daniel Berger : > Hi all, > > I'm working on the EventLog#read method for the pure Ruby version of > win32-eventlog, but I'm stuck on the get_description private method. > > Here are the problems: > > * I don't think I'm advancing the EVENTLOGRECORD properly between > iterations. Take a look at the end of the "while dwread > 0" loop. I > get some records, but not all of them. > > * I'm not sure how to properly populate or pack/unpack the va_list, > which is later passed to the FormatMessage() function. > > Please take a look. > > Thanks, > > Dan Here is the patch: --- eventlog.rb 2006-05-17 10:40:34.000000000 +0900 +++ eventlog.rb.new 2006-05-17 12:46:18.978361600 +0900 @@ -227,6 +227,7 @@ struct.event_type = event_type struct.user = user struct.category = buf[26,2].unpack('S').first + struct.description = desc if block_given? yield struct @@ -239,9 +240,9 @@ end length = buf[0,4].unpack('L').first # Length - - dwread -= buf.strip.length - buf += 0.chr * length + + dwread -= length + buf = buf[length..-1] end buf = 0.chr * BUFFER_SIZE @@ -254,19 +255,20 @@ private # TODO: finish - def get_description(rec, event_source) - str = rec[36,4].unpack('L').first # StringOffset + def get_description(rec, event_source) + str = [rec].pack('P').unpack('L').first + rec[36,4].unpack('L').first # StringOffset num = rec[24,2].unpack('S').first # NumStrings hkey = [0].pack('L') key = BASE_KEY + "#{@source}\\#{event_source}" va_list = [] + buf = 0.chr * 1024 # TODO: Fix this loop 0.upto(num){ va_list.push(str) str += str.size + 1 } - + va_list_ptr = va_list.pack('L*') if RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, hkey) == 0 value = 'EventMessageFile' file = 0.chr * MAX_SIZE @@ -284,9 +286,7 @@ hmodule = LoadLibraryEx(file, 0, LOAD_LIBRARY_AS_DATAFILE) event_id = rec[20,4].unpack('L').first if hmodule != 0 - buf = 0.chr * 260 FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, @@ -295,7 +295,7 @@ 0, buf, buf.size, - va_list # TODO: unpack this properly + va_list_ptr ) FreeLibrary(hmodule) end @@ -304,6 +304,6 @@ RegCloseKey(hkey) end + buf.strip end Regards, Park Heesob From Daniel.Berger at qwest.com Wed May 17 14:06:45 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 17 May 2006 13:06:45 -0500 Subject: [Win32utils-devel] Need a little help with the pure Rubywin32-eventlog Message-ID: <39AA6550E5AA554AB1456707D6E5563DBD003D@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Tuesday, May 16, 2006 9:51 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Need a little help with the > pure Rubywin32-eventlog > > > Hi, > > 2006/5/17, Daniel Berger : > > Hi all, > > > > I'm working on the EventLog#read method for the pure Ruby > version of > > win32-eventlog, but I'm stuck on the get_description private method. > > > > Here are the problems: > > > > * I don't think I'm advancing the EVENTLOGRECORD properly between > > iterations. Take a look at the end of the "while dwread > > 0" loop. I > > get some records, but not all of them. > > > > * I'm not sure how to properly populate or pack/unpack the va_list, > > which is later passed to the FormatMessage() function. > > > > Please take a look. > > > > Thanks, > > > > Dan > > Here is the patch: Thanks. That mostly seems to work. However, I'm hitting a segfault after a few records. As far as I can tell this happens when +buf+ is empty, but I'm not positive that's the culprit. I also noticed that FormatMessage's parameter list is defined as 'LPLLPLP' in error.rb (from windows-pr). Thinking that might be the culprit I tried changing the second param to 'L', but that didn't seem to have any effect. Any ideas? Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Wed May 17 17:26:11 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 17 May 2006 16:26:11 -0500 Subject: [Win32utils-devel] Need a little help with the pureRubywin32-eventlog Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E65B@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Berger, Daniel > Sent: Wednesday, May 17, 2006 12:07 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Need a little help with the > pureRubywin32-eventlog > > > > -----Original Message----- > > From: win32utils-devel-bounces at rubyforge.org > > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > > Heesob Park > > Sent: Tuesday, May 16, 2006 9:51 PM > > To: Development and ideas for win32utils projects > > Subject: Re: [Win32utils-devel] Need a little help with the > > pure Rubywin32-eventlog > > > > > > Hi, > > > > 2006/5/17, Daniel Berger : > > > Hi all, > > > > > > I'm working on the EventLog#read method for the pure Ruby > > version of > > > win32-eventlog, but I'm stuck on the get_description > private method. > > > > > > Here are the problems: > > > > > > * I don't think I'm advancing the EVENTLOGRECORD properly between > > > iterations. Take a look at the end of the "while dwread > > > 0" loop. I > > > get some records, but not all of them. > > > > > > * I'm not sure how to properly populate or pack/unpack > the va_list, > > > which is later passed to the FormatMessage() function. > > > > > > Please take a look. > > > > > > Thanks, > > > > > > Dan > > > > Here is the patch: > > > > Thanks. That mostly seems to work. However, I'm hitting a > segfault after a few records. As far as I can tell this > happens when +buf+ is empty, but I'm not positive that's the culprit. > > I also noticed that FormatMessage's parameter list is defined > as 'LPLLPLP' in error.rb (from windows-pr). Thinking that > might be the culprit I tried changing the second param to > 'L', but that didn't seem to have any effect. > > Any ideas? > > Dan Here's some more info. Using the C version of win32-eventlog I can see the record in question looks like this: # The description length is 664, so we should have enough buffer space. Hm...looking at the records that precede it, this appears to be the first description that contains "\r\n" in it. In other news I don't think the user code is right. The pure Ruby version returns 'djberge' for the user instead of nil as it should. HTH, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Wed May 17 22:29:28 2006 From: phasis at gmail.com (Heesob Park) Date: Thu, 18 May 2006 11:29:28 +0900 Subject: [Win32utils-devel] Need a little help with the pureRubywin32-eventlog In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E65B@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E65B@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: Hi, 2006/5/18, Berger, Daniel : > > > > -----Original Message----- > > From: win32utils-devel-bounces at rubyforge.org > > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > > Berger, Daniel > > Sent: Wednesday, May 17, 2006 12:07 PM > > To: Development and ideas for win32utils projects > > Subject: Re: [Win32utils-devel] Need a little help with the > > pureRubywin32-eventlog > > > > > > > -----Original Message----- > > > From: win32utils-devel-bounces at rubyforge.org > > > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > > > Heesob Park > > > Sent: Tuesday, May 16, 2006 9:51 PM > > > To: Development and ideas for win32utils projects > > > Subject: Re: [Win32utils-devel] Need a little help with the > > > pure Rubywin32-eventlog > > > > > > > > > Hi, > > > > > > 2006/5/17, Daniel Berger : > > > > Hi all, > > > > > > > > I'm working on the EventLog#read method for the pure Ruby > > > version of > > > > win32-eventlog, but I'm stuck on the get_description > > private method. > > > > > > > > Here are the problems: > > > > > > > > * I don't think I'm advancing the EVENTLOGRECORD properly between > > > > iterations. Take a look at the end of the "while dwread > > > > 0" loop. I > > > > get some records, but not all of them. > > > > > > > > * I'm not sure how to properly populate or pack/unpack > > the va_list, > > > > which is later passed to the FormatMessage() function. > > > > > > > > Please take a look. > > > > > > > > Thanks, > > > > > > > > Dan > > > > > > Here is the patch: > > > > > > > > Thanks. That mostly seems to work. However, I'm hitting a > > segfault after a few records. As far as I can tell this > > happens when +buf+ is empty, but I'm not positive that's the culprit. > > > > I also noticed that FormatMessage's parameter list is defined > > as 'LPLLPLP' in error.rb (from windows-pr). Thinking that > > might be the culprit I tried changing the second param to > > 'L', but that didn't seem to have any effect. > > > > Any ideas? > > > > Dan > > Here's some more info. Using the C version of win32-eventlog I can see > the record in question looks like this: > > # Mar 18 23:13:43 MST 2006, ti > me_written=Sat Mar 18 23:13:43 MST 2006, event_id=11203, > event_type="error", category=0, source="Sms > Client", computer="CO3840GDJBERGEX", user=nil, description="Software > updates evaluation failed: coul > d not locate the scan component of the specified software update > inventory tool. The scan component > advertisement might not have run on the client > computer.\r\n\r\nPossible cause: Incorrect package a > nd program name in the Scan.ini file.\r\nSolution: Verify that the > package and program name specifi > ed in the scan.ini file are correct.\r\n\r\nPossible cause: Scan > component was never run on client.\ > r\nSolution: Specify that the scan component is run in a program > dependency of the software updates > package. This will ensure that new client computers always run the scan > component before software up > date installation is attempted."> > > The description length is 664, so we should have enough buffer space. > Hm...looking at the records that precede it, this appears to be the > first description that contains "\r\n" in it. > > In other news I don't think the user code is right. The pure Ruby > version returns 'djberge' for the user instead of nil as it should. > > HTH, > > Dan > The user,computer,cateogory code were wrong. Here is the patch for the CVS version: --- eventlog.rb 2006-05-17 10:40:34.000000000 +0900 +++ eventlog.rb.new 2006-05-18 10:49:45.990803200 +0900 @@ -209,13 +209,14 @@ dwread = read.unpack('L').first event_type = get_event_type(buf[24,2].unpack('S').first) - user = get_user(buf) + while dwread > 0 struct = EventLogStruct.new event_source = buf[56..-1].split(0.chr).first - computer = buf[56 + source.length + 1..-1].split(0.chr).first + computer = buf[56 + event_source.length + 1..-1].split(0.chr).first + user = get_user(buf) desc = get_description(buf, event_source) struct.source = event_source @@ -226,8 +227,9 @@ struct.event_id = buf[20,4].unpack('L').first & 0x0000FFFF struct.event_type = event_type struct.user = user - struct.category = buf[26,2].unpack('S').first - + struct.category = buf[28,2].unpack('S').first + struct.description = desc + if block_given? yield struct else @@ -239,9 +241,9 @@ end length = buf[0,4].unpack('L').first # Length - - dwread -= buf.strip.length - buf += 0.chr * length + + dwread -= length + buf = buf[length..-1] end buf = 0.chr * BUFFER_SIZE @@ -254,19 +256,20 @@ private # TODO: finish - def get_description(rec, event_source) - str = rec[36,4].unpack('L').first # StringOffset - num = rec[24,2].unpack('S').first # NumStrings + def get_description(rec, event_source) + str = rec[ rec[36,4].unpack('L').first .. -1] + num = rec[26,2].unpack('S').first # NumStrings hkey = [0].pack('L') key = BASE_KEY + "#{@source}\\#{event_source}" - va_list = [] + buf = 0.chr * 1024 - # TODO: Fix this loop - 0.upto(num){ - va_list.push(str) - str += str.size + 1 - } - + if num==0 + va_list_ptr = 0.chr * 4 + else + va_list = str.split(0.chr)[0...num] + va_list_ptr = va_list.map {|x| [x+0.chr].pack('P').unpack('L').first }.pack('L*') + end + if RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, hkey) == 0 value = 'EventMessageFile' file = 0.chr * MAX_SIZE @@ -284,9 +287,7 @@ hmodule = LoadLibraryEx(file, 0, LOAD_LIBRARY_AS_DATAFILE) event_id = rec[20,4].unpack('L').first if hmodule != 0 - buf = 0.chr * 260 FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, @@ -295,7 +296,7 @@ 0, buf, buf.size, - va_list # TODO: unpack this properly + va_list_ptr ) FreeLibrary(hmodule) end @@ -304,4 +305,5 @@ RegCloseKey(hkey) end + buf.strip end Regards, Park Heesob From djberg96 at gmail.com Thu May 18 00:24:18 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 17 May 2006 22:24:18 -0600 Subject: [Win32utils-devel] Need a little help with the pureRubywin32-eventlog In-Reply-To: References: <39AA6550E5AA554AB1456707D6E5563D0259E65B@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <446BF6F2.4010406@gmail.com> Heesob Park wrote: > The user,computer,cateogory code were wrong. Ack. Thanks. > Here is the patch for the CVS version: Ok, I applied that patch but I'm still hitting a segfault, though after a much greater number of reads. The record it's segfaulting on has this in the description: wuauclt (364) The database engine 5.01.2600.2180 started. I had to manually edit the file, as I couldn't get the patch utility to work properly. So, it's possible I mistyped something, but I'm not seeing anything. If that's not enough info let me know and I'll attach a copy of the eventlog. Thanks, Dan From phasis at gmail.com Thu May 18 00:31:36 2006 From: phasis at gmail.com (Heesob Park) Date: Thu, 18 May 2006 13:31:36 +0900 Subject: [Win32utils-devel] Need a little help with the pureRubywin32-eventlog In-Reply-To: <446BF6F2.4010406@gmail.com> References: <39AA6550E5AA554AB1456707D6E5563D0259E65B@QTOMAE2K3M01.AD.QINTRA.COM> <446BF6F2.4010406@gmail.com> Message-ID: 2006/5/18, Daniel Berger : > Heesob Park wrote: > > > > > The user,computer,cateogory code were wrong. > > Ack. Thanks. > > > Here is the patch for the CVS version: > > Ok, I applied that patch but I'm still hitting a segfault, though after > a much greater number of reads. The record it's segfaulting on has this > in the description: > > wuauclt (364) The database engine 5.01.2600.2180 started. > > I had to manually edit the file, as I couldn't get the patch utility to > work properly. So, it's possible I mistyped something, but I'm not > seeing anything. > > If that's not enough info let me know and I'll attach a copy of the > eventlog. > > Thanks, > > Dan > Yes, that's not enough info:) Please, send me your eventlog copy. Regards, Park Heesob From Daniel.Berger at qwest.com Thu May 18 10:15:18 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 18 May 2006 09:15:18 -0500 Subject: [Win32utils-devel] Need a little help withthe pureRubywin32-eventlog Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E65C@QTOMAE2K3M01.AD.QINTRA.COM> Note to anyone paying attention - this was solved off list. Apparently I just goofed the patch. Dan > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Daniel Berger > Sent: Wednesday, May 17, 2006 10:24 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Need a little help withthe > pureRubywin32-eventlog > > > Heesob Park wrote: > > > > > The user,computer,cateogory code were wrong. > > Ack. Thanks. > > > Here is the patch for the CVS version: > > Ok, I applied that patch but I'm still hitting a segfault, > though after > a much greater number of reads. The record it's segfaulting > on has this > in the description: > > wuauclt (364) The database engine 5.01.2600.2180 started. > > I had to manually edit the file, as I couldn't get the patch > utility to > work properly. So, it's possible I mistyped something, but I'm not > seeing anything. > > If that's not enough info let me know and I'll attach a copy of the > eventlog. > > Thanks, > > Dan > > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel > This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From djberg96 at gmail.com Fri May 19 22:16:31 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 19 May 2006 20:16:31 -0600 Subject: [Win32utils-devel] EventLog#tail is broken Message-ID: <446E7BFF.4060209@gmail.com> I just discovered something awful. The EventLog#tail method does not work the way I thought it did. Instead of picking up new events as they're added, it's really just iterating backwards through the current event log backwards. Look at this sample below. The first record is correct. Then another event happens, but instead of the latest record, I get an *earlier* record. Thinking about the flags that are set, EVENTLOG_BACKWARDS_READ | EVENTLOG_SEQUENTIAL_READ in the read_last_event() function, it makes sense. It will read backwards sequentially. C:\eclipse\workspace\win32-eventlog>irb irb(main):001:0> require 'win32/eventlog' => true irb(main):002:0> include Win32 => Object irb(main):003:0> EventLog.open('Security').tail{ |log| p log } # # UGH. So, what's the solution? Just start at the offset returned by GetNumberOfEventLogRecords() and use EVENTLOG_FORWARDS_READ | EVENTLOG_SEEK_READ instead? Was it always like this and no one noticed? Did I goof a commit somewhere? Or are things actually working and I'm panicked for no reason? Dan From djberg96 at gmail.com Fri May 19 22:49:13 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 19 May 2006 20:49:13 -0600 Subject: [Win32utils-devel] EventLog#tail followup Message-ID: <446E83A9.10700@gmail.com> The solution I see is something like this: * Set a @last instance variable in the constructor. * In the read_last_record function, check to see if @last is nil. If it is nil, then it's our first read. Use the current approach, and set @last to the record number. * If @last isn't nil, use EVENTLOG_FORWARDS_READ | EVENTLOG_SEEK_READ flags instead, and use @last + 1 as the offset. I tested this in the pure Ruby version and it seems to work fine. Sound good? Dan From phasis at gmail.com Fri May 19 23:06:24 2006 From: phasis at gmail.com (Heesob Park) Date: Sat, 20 May 2006 12:06:24 +0900 Subject: [Win32utils-devel] EventLog#tail followup In-Reply-To: <446E83A9.10700@gmail.com> References: <446E83A9.10700@gmail.com> Message-ID: Hi, 2006/5/20, Daniel Berger : > The solution I see is something like this: > > * Set a @last instance variable in the constructor. > > * In the read_last_record function, check to see if @last is nil. If it > is nil, then it's our first read. Use the current approach, and set > @last to the record number. > > * If @last isn't nil, use EVENTLOG_FORWARDS_READ | EVENTLOG_SEEK_READ > flags instead, and use @last + 1 as the offset. > > I tested this in the pure Ruby version and it seems to work fine. > > Sound good? > That sounds reasonable. I searched some utilities of tail for event log. http://www.codeproject.com/tools/Tail_for_Win32.asp?df=100&forumid=26136&exp=0&select=677277 www.sysinternals.com/Utilities/PsLogList.html HTH, Park Heesob From djberg96 at gmail.com Sat May 20 21:41:48 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 20 May 2006 19:41:48 -0600 Subject: [Win32utils-devel] Possible problems with EventLog#write Message-ID: <446FC55C.2030204@gmail.com> Hi, I've got EventLog#write and EventLog.add_event_source methods done. Well, I *think* they're done, but I can't get the data (text) to work properly, and I'm not sure if it's a bug in my .mc file, the add_event_source method, the write method, or just a goof in my test file. The source, category and event id seem to be ok. However, the description always comes back with: The description for Event ID ( 3 ) in Source ( foo ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: test. Anyway, here's the .mc file (which I took from the tutorial.txt file) and the test file: ; foo.mc MessageId=0x1 SymbolicName=CATEGORY_ERROR Language=English error . MessageId=0x2 SymbolicName=CATEGORY_WARNING Language=English warning . MessageId=0x3 Severity=Error SymbolicName=FOO_ERROR Language=English Error: %1 . # add.rb dll_file = Dir.pwd + '/foo.dll' EventLog.add_event_source( "key_name" => "foo", "category_count" => 2, "event_message_file" => dll_file, "category_message_file" => dll_file ) # test.rb require 'win32/eventlog' include Win32 log = EventLog.open log.write( :source => 'foo', :data => 'test', :category => 0x2, :event_id => 0x3, :event_type => EventLog::WARN ) log.close I also made sure that it wasn't a path separator issue by doing a String#tr in the add_event_source, but that didn't seem to matter. Also, I'm not sure that doing File.expand_path on the dll name within add_event_source is a good idea - I just tossed that in there for now, but I'm curious what others think. Thanks, Dan From phasis at gmail.com Sun May 21 02:39:19 2006 From: phasis at gmail.com (Heesob Park) Date: Sun, 21 May 2006 15:39:19 +0900 Subject: [Win32utils-devel] Possible problems with EventLog#write In-Reply-To: <446FC55C.2030204@gmail.com> References: <446FC55C.2030204@gmail.com> Message-ID: Hi, 2006/5/21, Daniel Berger : > Hi, > > I've got EventLog#write and EventLog.add_event_source methods done. > Well, I *think* they're done, but I can't get the data (text) to work > properly, and I'm not sure if it's a bug in my .mc file, the > add_event_source method, the write method, or just a goof in my test file. > > The source, category and event id seem to be ok. However, the > description always comes back with: > > The description for Event ID ( 3 ) in Source ( foo ) cannot be found. > The local computer may not have the necessary registry information or > message DLL files to display messages from a remote computer. You may be > able to use the /AUXSOURCE= flag to retrieve this description; see Help > and Support for details. The following information is part of the event: > test. > > Anyway, here's the .mc file (which I took from the tutorial.txt file) > and the test file: > > ; foo.mc > MessageId=0x1 > SymbolicName=CATEGORY_ERROR > Language=English > error > . > > MessageId=0x2 > SymbolicName=CATEGORY_WARNING > Language=English > warning > . > > MessageId=0x3 > Severity=Error > SymbolicName=FOO_ERROR > Language=English > Error: %1 > . > event_id is defined in the mc.h Look at the mc.h : #define CATEGORY_ERROR 0x00000001L #define CATEGORY_WARNING 0x00000002L #define FOO_ERROR 0xC0000003L > # add.rb > dll_file = Dir.pwd + '/foo.dll' > EventLog.add_event_source( > "key_name" => "foo", > "category_count" => 2, > "event_message_file" => dll_file, > "category_message_file" => dll_file > ) > > # test.rb > require 'win32/eventlog' > include Win32 > > log = EventLog.open > > log.write( > :source => 'foo', > :data => 'test', > :category => 0x2, > :event_id => 0x3, > :event_type => EventLog::WARN > ) > > log.close > You must call with event_id value 0xC0000003 instead of 0x3. But it raises error test.rb:7:in `write': bignum too big to convert into `long' (RangeError) from test.rb:7 It is another problem. > I also made sure that it wasn't a path separator issue by doing a > String#tr in the add_event_source, but that didn't seem to matter. > > Also, I'm not sure that doing File.expand_path on the dll name within > add_event_source is a good idea - I just tossed that in there for now, > but I'm curious what others think. > And tail method raises insufficient resource error after reading six event log messages. Regards, Park Heesob From luislavena at gmail.com Sun May 21 09:12:21 2006 From: luislavena at gmail.com (Luis Lavena) Date: Sun, 21 May 2006 10:12:21 -0300 Subject: [Win32utils-devel] Mongrel as win32-service, round3. Message-ID: <71166b3b0605210612x5b1c0c2ey7da2cd0b8e844231@mail.gmail.com> Hello lists! This is not spam, but included the 2 lists (mongrel-users and win32utils-devel) because the both are involved. Attached is the 3rd version of a simple http_service script used previously to get the things right for the mongrel Rails service. With the modifications Zed implemented the past days (into the beta gem, 0.3.13). Now the service part works better. Still, a few things must be worked to get rails 100% in this env. I also commented into the file a few things about how service work: You cannot do file operations (like openning a file and logging into it) inside service_stop, or actually stopping the listeners threads user by mongrel make the service hang and report an error. Found that the rb_funcall() to service_stop (if defined) is done previously to setting the service state to SERVICE_STOP_PENDING, a thing that sometimes make the service manager think the service just crashed. So far, tested in Windows XP SP2 without any kind of problems (runned 50 start/serve/stop cycles). Any feedback on this will be helpful, so I attached a Rakefile that should be used to perform the same test cycles I have done here. (You will need ApacheBench or replace the worker definitin with something that could give some load the the mongrel service). When it finish (or report errors) please mail me the service and stress log files. Thanks in advance for the time everyone take on this. Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- A non-text attachment was scrubbed... Name: http_service3.rb Type: application/octet-stream Size: 4149 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060521/5ee5b700/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: Rakefile Type: application/octet-stream Size: 575 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060521/5ee5b700/attachment-0001.obj From djberg96 at gmail.com Sun May 21 18:42:49 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 21 May 2006 16:42:49 -0600 Subject: [Win32utils-devel] Possible problems with EventLog#write In-Reply-To: References: <446FC55C.2030204@gmail.com> Message-ID: <4470ECE9.9030204@gmail.com> Heesob Park wrote: > Hi, > > 2006/5/21, Daniel Berger : >> Hi, >> >> I've got EventLog#write and EventLog.add_event_source methods done. >> Well, I *think* they're done, but I can't get the data (text) to work >> properly, and I'm not sure if it's a bug in my .mc file, the >> add_event_source method, the write method, or just a goof in my test file. >> >> The source, category and event id seem to be ok. However, the >> description always comes back with: >> >> The description for Event ID ( 3 ) in Source ( foo ) cannot be found. >> The local computer may not have the necessary registry information or >> message DLL files to display messages from a remote computer. You may be >> able to use the /AUXSOURCE= flag to retrieve this description; see Help >> and Support for details. The following information is part of the event: >> test. >> >> Anyway, here's the .mc file (which I took from the tutorial.txt file) >> and the test file: >> >> ; foo.mc >> MessageId=0x1 >> SymbolicName=CATEGORY_ERROR >> Language=English >> error >> . >> >> MessageId=0x2 >> SymbolicName=CATEGORY_WARNING >> Language=English >> warning >> . >> >> MessageId=0x3 >> Severity=Error >> SymbolicName=FOO_ERROR >> Language=English >> Error: %1 >> . >> > event_id is defined in the mc.h > > Look at the mc.h : > > #define CATEGORY_ERROR 0x00000001L > > #define CATEGORY_WARNING 0x00000002L > > #define FOO_ERROR 0xC0000003L > >> # add.rb >> dll_file = Dir.pwd + '/foo.dll' >> EventLog.add_event_source( >> "key_name" => "foo", >> "category_count" => 2, >> "event_message_file" => dll_file, >> "category_message_file" => dll_file >> ) >> >> # test.rb >> require 'win32/eventlog' >> include Win32 >> >> log = EventLog.open >> >> log.write( >> :source => 'foo', >> :data => 'test', >> :category => 0x2, >> :event_id => 0x3, >> :event_type => EventLog::WARN >> ) >> >> log.close >> > > You must call with event_id value 0xC0000003 instead of 0x3. > > But it raises error > test.rb:7:in `write': bignum too big to convert into `long' (RangeError) > from test.rb:7 > > It is another problem. I take it Win32API.c would have to be modified to use ULL2NUM. :( > >> I also made sure that it wasn't a path separator issue by doing a >> String#tr in the add_event_source, but that didn't seem to matter. >> >> Also, I'm not sure that doing File.expand_path on the dll name within >> add_event_source is a good idea - I just tossed that in there for now, >> but I'm curious what others think. >> > And tail method raises insufficient resource error after reading six > event log messages. Confirmed. I tried wrapping the WaitForSingleObject() function in its own thread and/or calling GC.start but that didn't seem to help. Any ideas? Dan From phasis at gmail.com Sun May 21 21:32:59 2006 From: phasis at gmail.com (Heesob Park) Date: Mon, 22 May 2006 10:32:59 +0900 Subject: [Win32utils-devel] Possible problems with EventLog#write In-Reply-To: <4470ECE9.9030204@gmail.com> References: <446FC55C.2030204@gmail.com> <4470ECE9.9030204@gmail.com> Message-ID: Hi, 2006/5/22, Daniel Berger : > Heesob Park wrote: > > Hi, > > > > 2006/5/21, Daniel Berger : > >> Hi, > >> > >> I've got EventLog#write and EventLog.add_event_source methods done. > >> Well, I *think* they're done, but I can't get the data (text) to work > >> properly, and I'm not sure if it's a bug in my .mc file, the > >> add_event_source method, the write method, or just a goof in my test file. > >> > >> The source, category and event id seem to be ok. However, the > >> description always comes back with: > >> > >> The description for Event ID ( 3 ) in Source ( foo ) cannot be found. > >> The local computer may not have the necessary registry information or > >> message DLL files to display messages from a remote computer. You may be > >> able to use the /AUXSOURCE= flag to retrieve this description; see Help > >> and Support for details. The following information is part of the event: > >> test. > >> > >> Anyway, here's the .mc file (which I took from the tutorial.txt file) > >> and the test file: > >> > >> ; foo.mc > >> MessageId=0x1 > >> SymbolicName=CATEGORY_ERROR > >> Language=English > >> error > >> . > >> > >> MessageId=0x2 > >> SymbolicName=CATEGORY_WARNING > >> Language=English > >> warning > >> . > >> > >> MessageId=0x3 > >> Severity=Error > >> SymbolicName=FOO_ERROR > >> Language=English > >> Error: %1 > >> . > >> > > event_id is defined in the mc.h > > > > Look at the mc.h : > > > > #define CATEGORY_ERROR 0x00000001L > > > > #define CATEGORY_WARNING 0x00000002L > > > > #define FOO_ERROR 0xC0000003L > > > >> # add.rb > >> dll_file = Dir.pwd + '/foo.dll' > >> EventLog.add_event_source( > >> "key_name" => "foo", > >> "category_count" => 2, > >> "event_message_file" => dll_file, > >> "category_message_file" => dll_file > >> ) > >> > >> # test.rb > >> require 'win32/eventlog' > >> include Win32 > >> > >> log = EventLog.open > >> > >> log.write( > >> :source => 'foo', > >> :data => 'test', > >> :category => 0x2, > >> :event_id => 0x3, > >> :event_type => EventLog::WARN > >> ) > >> > >> log.close > >> > > > > You must call with event_id value 0xC0000003 instead of 0x3. > > > > But it raises error > > test.rb:7:in `write': bignum too big to convert into `long' (RangeError) > > from test.rb:7 > > > > It is another problem. > > I take it Win32API.c would have to be modified to use ULL2NUM. :( > > > > >> I also made sure that it wasn't a path separator issue by doing a > >> String#tr in the add_event_source, but that didn't seem to matter. > >> > >> Also, I'm not sure that doing File.expand_path on the dll name within > >> add_event_source is a good idea - I just tossed that in there for now, > >> but I'm curious what others think. > >> > > And tail method raises insufficient resource error after reading six > > event log messages. > > Confirmed. I tried wrapping the WaitForSingleObject() function in its > own thread and/or calling GC.start but that didn't seem to help. Any ideas? > One workaround is open event log every time like this: def notify_change(&block) @handle = OpenEventLog(@server, @source) unless block_given? raise EventLogError, 'block missing for notify_change()' end event = CreateEvent(0, 0, 0, 0) unless NotifyChangeEventLog(@handle, event) error = 'NotifyChangeEventLog() failed: ' + get_last_error raise EventLogError, error end wait_result = WaitForSingleObject(event, INFINITE) CloseHandle(event) if wait_result == WAIT_FAILED error = 'WaitForSingleObject() failed: ' + get_last_error raise EventLogError, error else last = read_last_event block.call(last) end CloseEventLog(@handle) self end The other is GetNumberOfEventLogRecords instead of NotifyChangeEventLog refer to http://support.microsoft.com/kb/q245609/ Regards, Park Heesob From djberg96 at gmail.com Sun May 21 23:48:11 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 21 May 2006 21:48:11 -0600 Subject: [Win32utils-devel] Possible problems with EventLog#write In-Reply-To: References: <446FC55C.2030204@gmail.com> <4470ECE9.9030204@gmail.com> Message-ID: <4471347B.9080003@gmail.com> Heesob Park wrote: > One workaround is open event log every time like this: > > def notify_change(&block) > @handle = OpenEventLog(@server, @source) > unless block_given? > raise EventLogError, 'block missing for notify_change()' > end > event = CreateEvent(0, 0, 0, 0) > unless NotifyChangeEventLog(@handle, event) > error = 'NotifyChangeEventLog() failed: ' + get_last_error > raise EventLogError, error > end > wait_result = WaitForSingleObject(event, INFINITE) > CloseHandle(event) > > if wait_result == WAIT_FAILED > error = 'WaitForSingleObject() failed: ' + get_last_error > raise EventLogError, error > else > last = read_last_event > block.call(last) > end > CloseEventLog(@handle) > self > end For some reason this didn't work right. It would start returning empty structs if too many events happened too quickly. > The other is GetNumberOfEventLogRecords instead of NotifyChangeEventLog > refer to http://support.microsoft.com/kb/q245609/ The problem with that approach is that, according to other docs I've read, the record numbers can get reused. That leads me to believe that GetNumberOfEventLogRecords() would not necessarily correspond to the last record number. However, I took that general idea and came up with this solution: # Remove references to the @last instance variable first def tail(frequency=5) unless block_given? raise EventLogError, 'block missing for tail()' end old_total = total_records() flags = FORWARDS_READ | SEEK_READ rec_num = read_last_event.record_number while true new_total = total_records() if new_total != old_total read(flags, rec_num).each{ |log| yield log } old_total = new_total rec_num = read_last_event.record_number end sleep frequency end end I tail'd the Security log (where I could force lots of log entries by doing some random things with user accounts) and it handled it just fine. If you see any problems with this approach please let me know. Otherwise, I'm going to commit it later this week (along with updated docs). However, that still leaves us with the bigint/long issue. Many thanks, Dan From phasis at gmail.com Mon May 22 01:22:02 2006 From: phasis at gmail.com (Heesob Park) Date: Mon, 22 May 2006 14:22:02 +0900 Subject: [Win32utils-devel] Possible problems with EventLog#write In-Reply-To: <4471347B.9080003@gmail.com> References: <446FC55C.2030204@gmail.com> <4470ECE9.9030204@gmail.com> <4471347B.9080003@gmail.com> Message-ID: Hi, 2006/5/22, Daniel Berger : > Heesob Park wrote: > > > However, I took that general idea and came up with this solution: > > # Remove references to the @last instance variable first > def tail(frequency=5) > unless block_given? > raise EventLogError, 'block missing for tail()' > end > > old_total = total_records() > flags = FORWARDS_READ | SEEK_READ > rec_num = read_last_event.record_number > > while true > new_total = total_records() > if new_total != old_total > read(flags, rec_num).each{ |log| yield log } > old_total = new_total > rec_num = read_last_event.record_number > end > sleep frequency > end > end > > I tail'd the Security log (where I could force lots of log entries by > doing some random things with user accounts) and it handled it just fine. > > If you see any problems with this approach please let me know. > Otherwise, I'm going to commit it later this week (along with updated docs). > It works fine. go ahead. > However, that still leaves us with the bigint/long issue. > The bigint/long issue is only in c version of eventlog. The source eventlog.c line #711 dwEventID = NUM2INT(v_event_id); should be dwEventID = NUM2ULONG(v_event_id); Pure ruby version works fine. Regards, Park Heesob From luislavena at gmail.com Mon May 22 12:00:36 2006 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 22 May 2006 13:00:36 -0300 Subject: [Win32utils-devel] win32/service... still with problems. Message-ID: <71166b3b0605220900n1556e6a2wac8210657aa170d5@mail.gmail.com> Hello list, In my quest to get Mongrel working as service for win32, found some problems with win32/service that make it impossible to solve. Attached is the simplest service script I could do with ruby, which depends on win32/service. I found that doing anything complex in service_stop (killing threads, doing file handling, even sleeping for 0.25 seconds). crash the service with backtraces (of the service) like this: dead_service.rb:119:in `service_main': uninitialized constant RUNNING (NameError) from U:/Programming/Sources/ruby/try/dead_service.rb:131 Just commenting the sleep command solves that problem, but leaves other issues there... like the impossible task of killing running threads (from a ThreadGroup, as example). Also, removing the while state == RUNNING loop solves the sleep and file handling issues, but still exist problems with already running threads that must be killed/stopped. Or: I'm doing something wrong (in which case please enlighten me) or there is something wrong on how the threading model is implemented? (and the mix of C threads with ruby threads). Thanks in advance for your time, Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- A non-text attachment was scrubbed... Name: dead_service.rb Type: application/octet-stream Size: 3360 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060522/1270f741/attachment.obj From Daniel.Berger at Qwest.com Mon May 22 12:53:48 2006 From: Daniel.Berger at Qwest.com (Berger, Daniel) Date: Mon, 22 May 2006 11:53:48 -0500 Subject: [Win32utils-devel] win32/service... still with problems. Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E67B@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Monday, May 22, 2006 10:01 AM > To: win32utils-devel at rubyforge.org > Subject: [Win32utils-devel] win32/service... still with problems. > > > Hello list, > > In my quest to get Mongrel working as service for win32, > found some problems with win32/service that make it > impossible to solve. > > Attached is the simplest service script I could do with ruby, > which depends on win32/service. > > I found that doing anything complex in service_stop (killing > threads, doing file handling, even sleeping for 0.25 > seconds). crash the service with backtraces (of the service) > like this: > > dead_service.rb:119:in `service_main': uninitialized constant RUNNING > (NameError) > from U:/Programming/Sources/ruby/try/dead_service.rb:131 Where does this backtrace go? I don't see anything like that when I tail the log file: 2006-05-22 10:38:48 - ** Dead Simple Service starting... 2006-05-22 10:38:50 - ** Done initialization. 2006-05-22 10:38:50 - Entering Service Main do nothing! I have no idea why you're seeing that error. I don't see it. There are a couple of issues with your script (which may actually be issues with our sample script). You should re-raise exceptions or exit when one of the commands fails. For example: rescue Win32::ServiceError => err puts "There was a problem installing the service:" puts err end Should be: rescue Win32::ServiceError => err puts "There was a problem installing the service:" puts err raise end Otherwise, you'll be dropping into a later part of the script, which is probably not what you want. > Or: I'm doing something wrong (in which case please enlighten > me) or there is something wrong on how the threading model is > implemented? (and the mix of C threads with ruby threads). I think one thing you'll want to avoid is having a Daemon calling methods outside of itself, as you're doing with the 'log' method there, which may be the source of the problem. Although the example we ship with the win32-service package mixes the command line stuff with the actual Daemon code, in practice I separate the actual Daemon class and the controller script into separate files. It's a good sanity preserver I've found. Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Mon May 22 13:26:32 2006 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 22 May 2006 14:26:32 -0300 Subject: [Win32utils-devel] win32/service... still with problems. In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E67B@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E67B@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <71166b3b0605221026i44e33fa4ud298cf24df2eacad@mail.gmail.com> On 5/22/06, Berger, Daniel wrote: > > Where does this backtrace go? I don't see anything like that when I > tail the log file: > > 2006-05-22 10:38:48 - ** Dead Simple Service starting... > 2006-05-22 10:38:50 - ** Done initialization. > 2006-05-22 10:38:50 - Entering Service Main > do nothing! > > I have no idea why you're seeing that error. I don't see it. > Actually, after the do nothing! you should see "Leaving Service Main", which don't happen (don't see why in your setup don't, but here it do, winxp). > There are a couple of issues with your script (which may actually be > issues with our sample script). You should re-raise exceptions or exit > when one of the commands fails. For example: > [...] > Otherwise, you'll be dropping into a later part of the script, which is > probably not what you want. The command part don't affect the Daemon part, both are discarted by the ARGV[0] and the ENV["HOMEDRIVE"]!=nil Anyway, followed your suggestions (split the ctrl and the daemon), with the same result: 2006-05-22 14:19:50 - ** Dead Simple Service starting... 2006-05-22 14:19:52 - ** Done initialization. 2006-05-22 14:19:52 - Entering Service Main 2006-05-22 14:20:00 - Stop Signal received. do nothing! U:/Programming/Sources/ruby/try/dead_service.rb:45:in `service_stop': uninitialized constant RUNNING (NameError) from U:/Programming/Sources/ruby/try/dead_service.rb:52:in `service_main' from U:/Programming/Sources/ruby/try/dead_service.rb:63 > I think one thing you'll want to avoid is having a Daemon calling > methods outside of itself, as you're doing with the 'log' method there, > which may be the source of the problem. [...] Removing the call to the outside function (donothing) solved the uninitialized constant problem, but the "Leaving Service Main" never shows, so looks like was terminated previously (no safe cleanup). -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- A non-text attachment was scrubbed... Name: dead_service.rb Type: application/octet-stream Size: 1564 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060522/8f9132b2/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: dead_service_ctrl.rb Type: application/octet-stream Size: 1972 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060522/8f9132b2/attachment-0001.obj From luislavena at gmail.com Mon May 22 13:30:32 2006 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 22 May 2006 14:30:32 -0300 Subject: [Win32utils-devel] win32/service... still with problems. In-Reply-To: <71166b3b0605221026i44e33fa4ud298cf24df2eacad@mail.gmail.com> References: <39AA6550E5AA554AB1456707D6E5563D0259E67B@QTOMAE2K3M01.AD.QINTRA.COM> <71166b3b0605221026i44e33fa4ud298cf24df2eacad@mail.gmail.com> Message-ID: <71166b3b0605221030l5cc575e7w579b2e4213d68f5c@mail.gmail.com> On 5/22/06, Luis Lavena wrote: [snip] Also, I'll like to add the randomness of the problem: 2006-05-22 14:28:17 - ** Dead Simple Service starting... 2006-05-22 14:28:19 - ** Done initialization. 2006-05-22 14:28:19 - Entering Service Main 2006-05-22 14:28:21 - Stop Signal received. 2006-05-22 14:28:28 - ** Dead Simple Service starting... 2006-05-22 14:28:30 - ** Done initialization. 2006-05-22 14:28:30 - Entering Service Main 2006-05-22 14:28:35 - Stop Signal received. 2006-05-22 14:28:37 - Leaving Service Main Started and stopped the service 2 times, the first left on service_stop, without cleanup/correct exit of service_main. The second time left ok, exiting the loop. Is a 50-50 chance of success with this? -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From Daniel.Berger at qwest.com Mon May 22 14:04:56 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 22 May 2006 13:04:56 -0500 Subject: [Win32utils-devel] win32/service... still with problems. Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E67D@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Monday, May 22, 2006 11:27 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] win32/service... still with problems. > Actually, after the do nothing! you should see "Leaving > Service Main", which don't happen (don't see why in your > setup don't, but here it do, winxp). I didn't see it because your 'log' method was defined outside of your daemon class. In fact, your script works just fine once you move those methods within the Daemon class itself. Attached is the script I'm using. Here was the output: 2006-05-22 11:58:09 - ** Dead Simple Service starting... 2006-05-22 11:58:11 - ** Done initialization. 2006-05-22 11:58:11 - Entering Service Main do nothing! 2006-05-22 11:58:49 - Leaving Service Main (I added some spaces there since Outlook is joining them into a single string for some reason). Hope that helps. Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. -------------- next part -------------- A non-text attachment was scrubbed... Name: dead_service.rb Type: application/octet-stream Size: 3515 bytes Desc: dead_service.rb Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060522/06bd0024/attachment-0001.obj From luislavena at gmail.com Mon May 22 14:38:02 2006 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 22 May 2006 15:38:02 -0300 Subject: [Win32utils-devel] win32/service... still with problems. In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E67D@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E67D@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <71166b3b0605221138l1edd8778h1b73bf64b505272d@mail.gmail.com> On 5/22/06, Berger, Daniel wrote: > I didn't see it because your 'log' method was defined outside of your > daemon class. In fact, your script works just fine once you move those > methods within the Daemon class itself. Attached is the script I'm > using. Here was the output: > > 2006-05-22 11:58:09 - ** Dead Simple Service starting... > > 2006-05-22 11:58:11 - ** Done initialization. > > 2006-05-22 11:58:11 - Entering Service Main > do nothing! > > 2006-05-22 11:58:49 - Leaving Service Main > > (I added some spaces there since Outlook is joining them into a single > string for some reason). > > Hope that helps. > > Dan Daniel, you tried more than 1 start/stop cycles? In the first run, everything worked ok, but several tries after it, showed that it works "sometimes" and other don't. (no matter if you left the service running for 1 second or 10 minutes) Even with these modifications, not always work. I find useless the service_stop method... sometimes it work, other don't. Moving the cleanup code from it to the service_main method (after the loop) also not always work, if the method is in the wrong point in time (like not evaluating state == RUNNING in that exact moment), the thread that runs service_main get terminated by the service.so If you see the attached version, service_stop will try to raise the Interrupt exception so the runner thread gets terminated. that won't happen... if you move these 2 lines to service_main and comment service_stop, it will work. But if you add code that need more time to of execution, the thread will get terminated: def service_main log "Entering Service Main" while state == RUNNING sleep 1 end log "Exiting main loop." @runner.raise Interrupt # slower cleanup... sleep 3 log "Leaving Service Main" end "Leaving Service Main" will never show up in the log, nor will wait 3 seconds. Maybe I don't get it, but I created a framework for service in FreeBASIC and also C++, with custom options for the events (onInit, Main, onStop, onShutdown). And these worked ok, but found that service.c:Service_Ctrl first execute the associated method with the EventArray and then set the service in a PENDING state, which 2 microseconds later get terminated by the evaluation of the controlcode and the set of StopEvent... So: slow code in service_stop make Service Manager think your service hang. Evaluating state in service_main is useless because you need the right timming (or luck) to evalaute it when was set, lucky enough don't get killed by the StopEvent raised... I'm getting it wrong? Please excuse my poor english (I try harder to express clearly what is happening) but english is not my native/natural language. Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi -------------- next part -------------- A non-text attachment was scrubbed... Name: dead_service.rb Type: application/octet-stream Size: 1735 bytes Desc: not available Url : http://rubyforge.org/pipermail/win32utils-devel/attachments/20060522/55975998/attachment.obj From Daniel.Berger at qwest.com Mon May 22 16:04:46 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Mon, 22 May 2006 15:04:46 -0500 Subject: [Win32utils-devel] win32/service... still with problems. Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E680@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Monday, May 22, 2006 12:38 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] win32/service... still with problems. > > > On 5/22/06, Berger, Daniel wrote: > > I didn't see it because your 'log' method was defined > outside of your > > daemon class. In fact, your script works just fine once you move > > those methods within the Daemon class itself. Attached is > the script > > I'm using. Here was the output: > > > > 2006-05-22 11:58:09 - ** Dead Simple Service starting... > > > > 2006-05-22 11:58:11 - ** Done initialization. > > > > 2006-05-22 11:58:11 - Entering Service Main > > do nothing! > > > > 2006-05-22 11:58:49 - Leaving Service Main > > > > (I added some spaces there since Outlook is joining them > into a single > > string for some reason). > > > > Hope that helps. > > > > Dan > > Daniel, you tried more than 1 start/stop cycles? Yes. I ran a series of start/stops as fast as my little fingers would let me. No problem. > In the first run, everything worked ok, but several tries > after it, showed that it works "sometimes" and other don't. > (no matter if you left the service running for 1 second or 10 minutes) When you say it didn't work, do you mean that the the service_main or service_stop hooks weren't called? Or some other error? > If you see the attached version, service_stop will try to > raise the Interrupt exception so the runner thread gets terminated. Ok, I see the same behavior you mention - the service_stop handler doesn't get executed for some reason. I think we're back to the thread issues that Heesob mentioned in a previous post about this. Heesob, care to weigh in? Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Mon May 22 16:32:26 2006 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 22 May 2006 17:32:26 -0300 Subject: [Win32utils-devel] win32/service... still with problems. In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E680@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E680@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <71166b3b0605221332g2af509b8xcde4f049a15ccd9e@mail.gmail.com> On 5/22/06, Berger, Daniel wrote: [...] > > > > Daniel, you tried more than 1 start/stop cycles? > > Yes. I ran a series of start/stops as fast as my little fingers would > let me. No problem. > Me too, I though was my pc, so dumped my p3 800mhz 512mb for a p4, 3.0ghz, 1gb... same results. > > In the first run, everything worked ok, but several tries > > after it, showed that it works "sometimes" and other don't. > > (no matter if you left the service running for 1 second or 10 minutes) > > When you say it didn't work, do you mean that the the service_main or > service_stop hooks weren't called? Or some other error? the service_stop hook is called, but the code in there is no executed, to the point the service stop responding and service manager report it that the pipe has ended or an exception ocurred. > > If you see the attached version, service_stop will try to > > raise the Interrupt exception so the runner thread gets terminated. > > Ok, I see the same behavior you mention - the service_stop handler > doesn't get executed for some reason. I think we're back to the thread > issues that Heesob mentioned in a previous post about this. > > Heesob, care to weigh in? > I didn't get the Heesob reply about this, maybe thats why I keep asking the same :-P On my freebasic (please, don't think freebasic as old basica, is more powerful than that, closer to c, but with basic syntax). Anyway, on my framework, I solved this problem executing my Main function (which will be service_main in the ruby side) in another thread and wait for it to terminate until I destroy the events. Also, wouldn't be more correct report to the service manager that SERVICE_STOP_PENDING (is stopping) before calling service_stop? in service.c:78-83 thre is executed from EventHookHash prior reporting the Service Manager that we received the stop signal and we are stopping. In service.c:114, dwControlCode is evaluated after setting the ServiceState, and if it was CONTROL_STOP, we set the Stop event, something that exit service_main prematurely. I don't think service.c could be implemented as pure ruby (due required native threads)... or not? Please excuse my english (again), I try to explain better I could, but is not easy due: complexity of the topic, and the self-learned nature of the language. Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From phasis at gmail.com Mon May 22 19:50:53 2006 From: phasis at gmail.com (Heesob Park) Date: Tue, 23 May 2006 08:50:53 +0900 Subject: [Win32utils-devel] win32/service... still with problems. In-Reply-To: <71166b3b0605221332g2af509b8xcde4f049a15ccd9e@mail.gmail.com> References: <39AA6550E5AA554AB1456707D6E5563D0259E680@QTOMAE2K3M01.AD.QINTRA.COM> <71166b3b0605221332g2af509b8xcde4f049a15ccd9e@mail.gmail.com> Message-ID: Hi, 2006/5/23, Luis Lavena : > On 5/22/06, Berger, Daniel wrote: > [...] > > > > > > Daniel, you tried more than 1 start/stop cycles? > > > > Yes. I ran a series of start/stops as fast as my little fingers would > > let me. No problem. > > > Me too, I though was my pc, so dumped my p3 800mhz 512mb for a p4, > 3.0ghz, 1gb... same results. > > > > In the first run, everything worked ok, but several tries > > > after it, showed that it works "sometimes" and other don't. > > > (no matter if you left the service running for 1 second or 10 minutes) > > > > When you say it didn't work, do you mean that the the service_main or > > service_stop hooks weren't called? Or some other error? > > the service_stop hook is called, but the code in there is no executed, > to the point the service stop responding and service manager report it > that the pipe has ended or an exception ocurred. > > > > If you see the attached version, service_stop will try to > > > raise the Interrupt exception so the runner thread gets terminated. > > > > Ok, I see the same behavior you mention - the service_stop handler > > doesn't get executed for some reason. I think we're back to the thread > > issues that Heesob mentioned in a previous post about this. > > > > Heesob, care to weigh in? > > > I didn't get the Heesob reply about this, maybe thats why I keep > asking the same :-P > I repeat the last answer. As you know,the win32-service is multithreaded application. But, Ruby's sleep or select is not compatible with the Thread of Windows. While executing sleep or select in ruby code,the other thread cannot do anything. To workaround this stopping problem, 1. Use loop of short sleep insthead of long sleep. ex) 10.times { sleep 1 } instead of sleep 10 2. Use nonblocking IO and socket. > On my freebasic (please, don't think freebasic as old basica, is more > powerful than that, closer to c, but with basic syntax). > > Anyway, on my framework, I solved this problem executing my Main > function (which will be service_main in the ruby side) in another > thread and wait for it to terminate until I destroy the events. > > Also, wouldn't be more correct report to the service manager that > SERVICE_STOP_PENDING (is stopping) before calling service_stop? in > service.c:78-83 thre is executed from EventHookHash prior reporting > the Service Manager that we received the stop signal and we are > stopping. > > In service.c:114, dwControlCode is evaluated after setting the > ServiceState, and if it was CONTROL_STOP, we set the Stop event, > something that exit service_main prematurely. > > I don't think service.c could be implemented as pure ruby (due > required native threads)... or not? > I tried but it would't work for now. The workaround of stopping problem for now is separate service control process and working process. In service_main, use system,fork or something create another ruby program for working process and send kill to it when stop requested. > Please excuse my english (again), I try to explain better I could, but > is not easy due: complexity of the topic, and the self-learned nature > of the language. > > Regards, > > -- > Luis Lavena > Multimedia systems > - Regards, Park Heesob From luislavena at gmail.com Tue May 23 08:28:08 2006 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 23 May 2006 09:28:08 -0300 Subject: [Win32utils-devel] win32/service... still with problems. In-Reply-To: References: <39AA6550E5AA554AB1456707D6E5563D0259E680@QTOMAE2K3M01.AD.QINTRA.COM> <71166b3b0605221332g2af509b8xcde4f049a15ccd9e@mail.gmail.com> Message-ID: <71166b3b0605230528g5dcbcb7bt14d47f74ea4f2352@mail.gmail.com> On 5/22/06, Heesob Park wrote: > As you know,the win32-service is multithreaded application. > But, Ruby's sleep or select is not compatible with the Thread of Windows. > While executing sleep or select in ruby code,the other thread cannot > do anything. > > To workaround this stopping problem, > > 1. Use loop of short sleep insthead of long sleep. > ex) 10.times { sleep 1 } instead of sleep 10 > > 2. Use nonblocking IO and socket. > Understand that, but wanted to "remark" that anything that take more than 1 seconds to cleanup in service_main get terminated, no matter if service_main finished or not. > The workaround of stopping problem for now is separate service control > process and working process. > In service_main, use system,fork or something create another ruby > program for working process and send kill to it when stop requested. > That will create 2 ruby process, one for the service (which will depend of svchost.exe) and a child process... If I send a kill signal, the child process will not cleanup properly, something we must avoid in a good coded application. For that approach, using srvany uses less memory than another ruby process... (just loading the service.so and no other things we use 6MB of memory). Anyway, long live to the threading model of Ruby! (better yet, hate Windows Threads). Another workaround will be create a native (compiled) exe that redirect stdin/stdout of the childprocess and execute the Cntrl-C to finish it properly. I could do it with 30k exe and less than 1.5mb footprint. > Regards, > > Park Heesob Thank you for the time you and Dan took answering my mails and testing the scripts. Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From Daniel.Berger at qwest.com Tue May 23 16:33:37 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 23 May 2006 15:33:37 -0500 Subject: [Win32utils-devel] Possible problems with EventLog#write Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E688@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Sunday, May 21, 2006 11:22 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Possible problems with EventLog#write > > > Hi, > > 2006/5/22, Daniel Berger : > > Heesob Park wrote: > > > > > > However, I took that general idea and came up with this solution: > > > > # Remove references to the @last instance variable first > > def tail(frequency=5) > > unless block_given? > > raise EventLogError, 'block missing for tail()' > > end > > > > old_total = total_records() > > flags = FORWARDS_READ | SEEK_READ > > rec_num = read_last_event.record_number > > > > while true > > new_total = total_records() > > if new_total != old_total > > read(flags, rec_num).each{ |log| yield log } > > old_total = new_total > > rec_num = read_last_event.record_number > > end > > sleep frequency > > end > > end > > > > I tail'd the Security log (where I could force lots of log > entries by > > doing some random things with user accounts) and it handled it just > > fine. > > > > If you see any problems with this approach please let me know. > > Otherwise, I'm going to commit it later this week (along > with updated > > docs). > > > It works fine. go ahead. Ok, I'm going to get it out sometime in the next few days. I got a bunch of the preliminary work out of the way last night, but I need to put out the next release of windows-pr first. > > However, that still leaves us with the bigint/long issue. > > > The bigint/long issue is only in c version of eventlog. > The source eventlog.c line #711 > dwEventID = NUM2INT(v_event_id); > should be > dwEventID = NUM2ULONG(v_event_id); > > Pure ruby version works fine. You're right, thank you. Well, I guess we won't have to worry about that any more. :) Thanks for you time and help. Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From noreply at rubyforge.org Thu May 25 12:33:06 2006 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Thu, 25 May 2006 09:33:06 -0700 Subject: [Win32utils-devel] [ win32utils-Feature Requests-2811 ] Add UNC support to file / dir Message-ID: <200605251633.k4PGX6oZ013091@rubyforge.org> Feature Requests item #2811, was opened at 2005-11-10 08:17 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=414&aid=2811&group_id=85 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: graham foster (fosterg2) Assigned to: Nobody (None) Summary: Add UNC support to file / dir Initial Comment: I'd like to see win32 support for UNC's on the file management level, i.e. FileUtils for Windows Enable UNC support for the following (with recursive options please) directory delete file delete file copy directory copy file move directory move Another option would be to add a 'map to driveletter' method (as once done, the existing FileUtils module works OK.) Not sure is this should be a win32 request or a FileUtils request?? Graham ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2006-05-25 09:33 Message: I'm inclined to say this should go in FileUtils. Unfortunately, it would probably never get added. I recommend submitting a patch on ruby-core. If they reject it, we'll add custom File.copy and File.move methods into win32-file. Sorry for the long delay in responding here. I wanted to get win32-file-stat and win32-file out the door before I considered this. - Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=414&aid=2811&group_id=85 From noreply at rubyforge.org Thu May 25 12:35:25 2006 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Thu, 25 May 2006 09:35:25 -0700 Subject: [Win32utils-devel] [ win32utils-Support Requests-4264 ] win32 process Message-ID: <200605251635.k4PGZPKN013326@rubyforge.org> Support Requests item #4264, was opened at 2006-04-26 12:07 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=4264&group_id=85 Category: Install Problem (example) Group: None >Status: Closed >Resolution: Rejected Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: win32 process Initial Comment: I try to use the fork example, but I only get the error message: ruby.exe Entry Point Not Found The procedure entry point GetProcessId could not be located in the dynamic link library KERNEL32.dll. What do I need to install else? MS ---------------------------------------------------------------------- Comment By: Daniel Berger (djberg96) Date: 2006-04-26 18:00 Message: I do check for GetProcessId in the extconf.rb file. You must be using the precompiled binary on Win2k or NT. You'll have to build it from source. - Dan ---------------------------------------------------------------------- Comment By: Park Heesob (phasis68) Date: 2006-04-26 17:25 Message: Hi, What's your OS? GetProcessId function requires Windows Vista or Windows XP SP1. For the OS not support GetProcessId, some modification on extconf.rb is required. Regards, Park Heesob ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=412&aid=4264&group_id=85 From djberg96 at gmail.com Fri May 26 00:27:13 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 25 May 2006 22:27:13 -0600 Subject: [Win32utils-devel] win32-dir, unicode Message-ID: <447683A1.3030009@gmail.com> Hi, I've got a preliminary version of the pure Ruby version of win32-dir in CVS. However, I was hoping to work out the Unicode issue. Run this: from = "C:\\test" to = "?????" Dir.mkdir(from) unless File.exists?(from) Dir.create_junction(to, from) It works, but my explorer (and dos) window shows the name garbled. I don't think it's a font encoding issue within Explorer, since I can create a folder called "?????" manually within Explorer and it looks correct. Any ideas? Dan From phasis at gmail.com Fri May 26 02:16:26 2006 From: phasis at gmail.com (Heesob Park) Date: Fri, 26 May 2006 15:16:26 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <447683A1.3030009@gmail.com> References: <447683A1.3030009@gmail.com> Message-ID: Hi, 2006/5/26, Daniel Berger :> Hi,>> I've got a preliminary version of the pure Ruby version of win32-dir in> CVS. However, I was hoping to work out the Unicode issue. Run this:>> from = "C:\\test"> to = "?????"> Dir.mkdir(from) unless File.exists?(from)> Dir.create_junction(to, from)>> It works, but my explorer (and dos) window shows the name garbled. I> don't think it's a font encoding issue within Explorer, since I can> create a folder called "?????" manually within Explorer and it looks> correct.>You can check whether the folder name is whether unicode or ansi ? How about some modification of create_function method like this: def self.create_junction(to, from,unicode=false) # Normalize the paths to.tr!('/', "\\") from.tr!('/', "\\") to_path = 0.chr * 260 from_path = 0.chr * 260 buf_target = 0.chr * 260 if GetFullPathName(from, from_path.size, from_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error endif unicode if GetFullPathNameW(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error endelse if GetFullPathName(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error endend to_path = to_path.split("\0\0").first from_path = from_path.split(0.chr).first # You can create a junction to a directory that already exists, so # long as it's empty. if unicode rv = CreateDirectoryW(to_path, 0) if rv == 0 && rv != ERROR_ALREADY_EXISTS raise StandardError, 'CreateDirectory() failed: ' + get_last_error end handle = CreateFileW( to_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0 )else rv = CreateDirectory(to_path, 0) if rv == 0 && rv != ERROR_ALREADY_EXISTS raise StandardError, 'CreateDirectory() failed: ' + get_last_error end handle = CreateFile( to_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0 )end...end And call like this:from = "C:\\test"Dir.mkdir(from) unless File.exists?(from)#unicode folder nameto = "\x95\x03\xBB\x03\xBB\x03\xAC\x03\xC3\x03\0\0" # "?????"Dir.create_junction(to, from,true)#ansi folder nameto = "ansi"Dir.create_junction(to, from,false) Regards, Park Heesob From djberg96 at gmail.com Fri May 26 15:12:46 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Fri, 26 May 2006 13:12:46 -0600 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: References: <447683A1.3030009@gmail.com> Message-ID: <4477532E.9020709@gmail.com> Heesob Park wrote: > Hi, > 2006/5/26, Daniel Berger :> Hi,>> I've got a preliminary version of the pure Ruby version of win32-dir in> CVS. However, I was hoping to work out the Unicode issue. Run this:>> from = "C:\\test"> to = "?????"> Dir.mkdir(from) unless File.exists?(from)> Dir.create_junction(to, from)>> It works, but my explorer (and dos) window shows the name garbled. I> don't think it's a font encoding issue within Explorer, since I can> create a folder called "?????" manually within Explorer and it looks> correct.>You can check whether the folder name is whether unicode or ansi ? > How about some modification of create_function method like this: > def self.create_junction(to, from,unicode=false) # Normalize the paths to.tr!('/', "\\") from.tr!('/', "\\") > to_path = 0.chr * 260 from_path = 0.chr * 260 buf_target = 0.chr * 260 > if GetFullPathName(from, from_path.size, from_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error endif unicode if GetFullPathNameW(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error endelse if GetFullPathName(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error endend to_path = to_path.split("\0\0").first from_path = from_path.split(0.chr).first > # You can create a junction to a directory that already exists, so # long as it's empty. > if unicode rv = CreateDirectoryW(to_path, 0) if rv == 0 && rv != ERROR_ALREADY_EXISTS raise StandardError, 'CreateDirectory() failed: ' + get_last_error end > handle = CreateFileW( to_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0 )else rv = CreateDirectory(to_path, 0) if rv == 0 && rv != ERROR_ALREADY_EXISTS raise StandardError, 'CreateDirectory() failed: ' + get_last_error end > handle = CreateFile( to_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0 )end...end > And call like this:from = "C:\\test"Dir.mkdir(from) unless File.exists?(from)#unicode folder nameto = "\x95\x03\xBB\x03\xBB\x03\xAC\x03\xC3\x03\0\0" # "?????"Dir.create_junction(to, from,true)#ansi folder nameto = "ansi"Dir.create_junction(to, from,false) > Regards, > Park Heesob > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel Hi Heesob, That came through as a single line for some reason... Anyway, I modified the approach somewhat. Instead of adding a 'unicode' flag, I altered the windows-pr package to wrap methods like this: def CreateDirectory(path, attributes) if $KCODE != 'NONE' CreateDirectoryW.call(path, attributes) != 0 else CreateDirectory.call(path, attributes) != 0 end end Within dir.rb, I did this: if $KCODE != 'NONE' to_path = to_path.split("\0\0").first else to_path = to_path.split(0.chr).first end However, after making those changes I got this: dir.rb:123:in `create_junction': DeviceIoControl() failed: The data present in the reparse point buffer is invalid. (RuntimeError). Does rdb need to be packed differently? BTW, I also tinkered with the idea of using IsTextUnicode(): def CreateDirectory(path, attributes) if IsTextUnicode(path, path.size, 0) CreateDirectoryW.call(path, attributes) != 0 else CreateDirectory.call(path, attributes) != 0 end end But this didn't seem to handle UCS-2, i.e it worked for "\x95\x03\xBB\x03\xBB\x03\xAC\x03\xC3\x03\0\0" but not "?????". I imagine it's also slower. Regards, Dan From phasis at gmail.com Sat May 27 08:25:16 2006 From: phasis at gmail.com (Heesob Park) Date: Sat, 27 May 2006 21:25:16 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <4477532E.9020709@gmail.com> References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> Message-ID: Hi, 2006/5/27, Daniel Berger :> Hi Heesob,>> That came through as a single line for some reason...>> Anyway, I modified the approach somewhat. Instead of adding a 'unicode'> flag, I altered the windows-pr package to wrap methods like this:>> def CreateDirectory(path, attributes)> if $KCODE != 'NONE'> CreateDirectoryW.call(path, attributes) != 0> else> CreateDirectory.call(path, attributes) != 0> end> end>> Within dir.rb, I did this:>> if $KCODE != 'NONE'> to_path = to_path.split("\0\0").first> else> to_path = to_path.split(0.chr).first> end>> However, after making those changes I got this:>> dir.rb:123:in `create_junction': DeviceIoControl() failed: The data> present in the reparse point buffer is invalid. (RuntimeError).>> Does rdb need to be packed differently?>> BTW, I also tinkered with the idea of using IsTextUnicode():>> def CreateDirectory(path, attributes)> if IsTextUnicode(path, path.size, 0)> CreateDirectoryW.call(path, attributes) != 0> else> CreateDirectory.call(path, attributes) != 0> end> end>> But this didn't seem to handle UCS-2, i.e it worked for> "\x95\x03\xBB\x03\xBB\x03\xAC\x03\xC3\x03\0\0" but not "?????". I> imagine it's also slower.>> Regards,>> Dan> _______________________________________________> win32utils-devel mailing list> win32utils-devel at rubyforge.org> http://rubyforge.org/mailman/listinfo/win32utils-develI have managed to succeed in creating junction with create_junction method. First modify multi_to_wide and wide_to_multi to support UTF8 and Ansi string.For english users, UTF8 encoding is sufficient but other languageusers like Korean, both UTF8 and Ansi are required. def multi_to_wide(str) cp = ($KCODE == 'UTF8') ? CP_UTF8 : CP_ACP buf = 0.chr * 260 int = MultiByteToWideChar(cp, 0, str, -1, buf, buf.size) if int > 0 buf[0, int*2] else str end end def wide_to_multi(str) cp = ($KCODE == 'UTF8') ? CP_UTF8 : CP_ACP buf = 0.chr * 260 int = WideCharToMultiByte(cp, 0, str, -1, buf, buf.size, 0, 0) if int > 0 buf[0, int] else str end end Second, modify create_junction method like this: def self.create_junction(to, from) # Normalize the paths to.tr!('/', "\\") from.tr!('/', "\\") to_path = 0.chr * 260 from_path = 0.chr * 260 buf_target = 0.chr * 260 from = multi_to_wide(from) to = multi_to_wide(to) if GetFullPathNameW.call(from, from_path.size, from_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error end if GetFullPathNameW.call(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error end to_path = to_path.strip+"\0\0\0" from_path = from_path.strip+"\0\0\0" # You can create a junction to a directory that already exists, so # long as it's empty. rv = CreateDirectoryW.call(to_path, 0) if rv == 0 && GetLastError.call != ERROR_ALREADY_EXISTS raise StandardError, 'CreateDirectory() failed: ' + get_last_error end handle = CreateFileW.call( to_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0 ) if handle == INVALID_HANDLE_VALUE raise StandardError, 'CreateFile() failed: ' + get_last_error end buf_target = multi_to_wide("\\??\\") length = buf_target.size-2 buf_target = buf_target[0,length] + from_path length = buf_target.size-2 wide_string = buf_target # REPARSE_JDATA_BUFFER rdb = [ "0xA0000003L".hex, # ReparseTag (IO_REPARSE_TAG_MOUNT_POINT) length + 12, # ReparseDataLength 0, # Reserved 0, # SubstituteNameOffset length, # SubstituteNameLength length + 2, # PrintNameOffset 0, # PrintNameLength wide_string # PathBuffer ].pack('LSSSSSSa' + (length + 4).to_s) bytes = [length].pack('L') bool = DeviceIoControl( handle, CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED,FILE_ANY_ACCESS), rdb, rdb.size, 0, 0, bytes, 0 ) unless bool error = 'DeviceIoControl() failed: ' + get_last_error RemoveDirectoryW.call(to_path) CloseHandle(handle) raise error end CloseHandle(handle) self end Make test.rb like this: from = "C:\\test"to = "?????"Dir.mkdir(from) unless File.exists?(from)Dir.create_junction(to, from) The file format must be UTF8 DOS format. Run with KCODE option like this: ruby -Ku test.rb Regards, Park Heesob From djberg96 at gmail.com Sun May 28 01:24:32 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 27 May 2006 23:24:32 -0600 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> Message-ID: <44793410.8060304@gmail.com> Heesob Park wrote: > Hi, > 2006/5/27, Daniel Berger :> Hi Heesob,>> That came through as a single line for some reason...>> Anyway, I modified the approach somewhat. Instead of adding a 'unicode'> flag, I altered the windows-pr package to wrap methods like this:>> def CreateDirectory(path, attributes)> if $KCODE != 'NONE'> CreateDirectoryW.call(path, attributes) != 0> else> CreateDirectory.call(path, attributes) != 0> end> end>> Within dir.rb, I did this:>> if $KCODE != 'NONE'> to_path = to_path.split("\0\0").first> else> to_path = to_path.split(0.chr).first> end>> However, after making those changes I got this:>> dir.rb:123:in `create_junction': DeviceIoControl() failed: The data> present in the reparse point buffer is invalid. (RuntimeError).>> Does rdb need to be packed differently?>> BTW, I also tinkered with the idea of using IsTextUnicode():>> def CreateDirectory(path, attributes)> if IsTextUnicode(path, path.size, 0)> CreateDirect oryW.call(path, attributes) != 0> else> CreateDirectory.call(path, attributes) != 0> end> end>> But this didn't seem to handle UCS-2, i.e it worked for> "\x95\x03\xBB\x03\xBB\x03\xAC\x03\xC3\x03\0\0" but not "?????". I> imagine it's also slower.>> Regards,>> Dan> _______________________________________________> win32utils-devel mailing list> win32utils-devel at rubyforge.org> http://rubyforge.org/mailman/listinfo/win32utils-develI have managed to succeed in creating junction with create_junction method. > First modify multi_to_wide and wide_to_multi to support UTF8 and Ansi string.For english users, UTF8 encoding is sufficient but other languageusers like Korean, both UTF8 and Ansi are required. > def multi_to_wide(str) cp = ($KCODE == 'UTF8') ? CP_UTF8 : CP_ACP buf = 0.chr * 260 int = MultiByteToWideChar(cp, 0, str, -1, buf, buf.size) if int > 0 buf[0, int*2] else str end end > def wide_to_multi(str) cp = ($KCODE == 'UTF8') ? CP_UTF8 : CP_ACP buf = 0.chr * 260 int = WideCharToMultiByte(cp, 0, str, -1, buf, buf.size, 0, 0) > if int > 0 buf[0, int] else str end end > Second, modify create_junction method like this: > > def self.create_junction(to, from) # Normalize the paths to.tr!('/', "\\") from.tr!('/', "\\") > to_path = 0.chr * 260 from_path = 0.chr * 260 buf_target = 0.chr * 260 > from = multi_to_wide(from) to = multi_to_wide(to) if GetFullPathNameW.call(from, from_path.size, from_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error end > if GetFullPathNameW.call(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error end > to_path = to_path.strip+"\0\0\0" from_path = from_path.strip+"\0\0\0" > # You can create a junction to a directory that already exists, so # long as it's empty. > rv = CreateDirectoryW.call(to_path, 0) if rv == 0 && GetLastError.call != ERROR_ALREADY_EXISTS raise StandardError, 'CreateDirectory() failed: ' + get_last_error end > handle = CreateFileW.call( to_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0 ) > if handle == INVALID_HANDLE_VALUE raise StandardError, 'CreateFile() failed: ' + get_last_error end buf_target = multi_to_wide("\\??\\") length = buf_target.size-2 buf_target = buf_target[0,length] + from_path length = buf_target.size-2 wide_string = buf_target > # REPARSE_JDATA_BUFFER rdb = [ "0xA0000003L".hex, # ReparseTag (IO_REPARSE_TAG_MOUNT_POINT) length + 12, # ReparseDataLength 0, # Reserved 0, # SubstituteNameOffset length, # SubstituteNameLength length + 2, # PrintNameOffset 0, # PrintNameLength wide_string # PathBuffer ].pack('LSSSSSSa' + (length + 4).to_s) > bytes = [length].pack('L') > > bool = DeviceIoControl( handle, CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED,FILE_ANY_ACCESS), rdb, rdb.size, 0, 0, bytes, 0 ) > unless bool error = 'DeviceIoControl() failed: ' + get_last_error > RemoveDirectoryW.call(to_path) CloseHandle(handle) raise error end > CloseHandle(handle) > self end > Make test.rb like this: > from = "C:\\test"to = "?????"Dir.mkdir(from) unless File.exists?(from)Dir.create_junction(to, from) > The file format must be UTF8 DOS format. > > Run with KCODE option like this: > ruby -Ku test.rb Thanks Heesob, but I'm getting some weird segfaults with wide character functions and buffers over 245 characters. I posted about this to ruby-talk as well. Here's some sample code that demonstrates the problem: require 'Win32API' GetFullPathNameW = Win32API.new('kernel32', 'GetFullPathNameW', 'PLPP', 'L') path = "C:\\test" buf = 0.chr * 260 # 245 or less works ok if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 puts "Failed" exit end p buf.split("\0\0").first # BOOM! I'm not sure what the significance of 245 or less is. I can inspect 'buf', copy and paste it to a separate editor as a string and run ops on it with no problem, so I'm very curious as to what's making Ruby segfault. Anyway, I think I'm not going to worry about Unicode support for the initial release of the pure Ruby version for now. Thanks, Dan From phasis at gmail.com Sun May 28 03:50:33 2006 From: phasis at gmail.com (Heesob Park) Date: Sun, 28 May 2006 16:50:33 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <44793410.8060304@gmail.com> References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> Message-ID: Hi, 2006/5/28, Daniel Berger : > Heesob Park wrote: > > Hi, > > Thanks Heesob, but I'm getting some weird segfaults with wide character > functions and buffers over 245 characters. I posted about this to > ruby-talk as well. Here's some sample code that demonstrates the problem: > > require 'Win32API' > > GetFullPathNameW = Win32API.new('kernel32', 'GetFullPathNameW', 'PLPP', 'L') > > path = "C:\\test" > buf = 0.chr * 260 # 245 or less works ok > > if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 > puts "Failed" > exit > end > > p buf.split("\0\0").first # BOOM! > > I'm not sure what the significance of 245 or less is. I can inspect > 'buf', copy and paste it to a separate editor as a string and run ops on > it with no problem, so I'm very curious as to what's making Ruby segfault. > I'm very curious too. Your sample code don't segfault. But I came across segfaults several times in modifing create_junction method. It's behaviour is very unstable, as I insert p method,it sometimes runs OK. It's location was mainly split method or get_last_error method. I guess it's not related with 245 or 260, but it seems to underlying C pointer memory access failure problem. Can you give me a sample stable segfault generating code? Regards, Park Heesob From djberg96 at gmail.com Sun May 28 09:39:52 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 28 May 2006 07:39:52 -0600 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> Message-ID: <4479A828.6030005@gmail.com> Heesob Park wrote: > Hi, > > 2006/5/28, Daniel Berger : >> Heesob Park wrote: >>> Hi, > >> Thanks Heesob, but I'm getting some weird segfaults with wide character >> functions and buffers over 245 characters. I posted about this to >> ruby-talk as well. Here's some sample code that demonstrates the problem: >> >> require 'Win32API' >> >> GetFullPathNameW = Win32API.new('kernel32', 'GetFullPathNameW', 'PLPP', 'L') >> >> path = "C:\\test" >> buf = 0.chr * 260 # 245 or less works ok >> >> if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 >> puts "Failed" >> exit >> end >> >> p buf.split("\0\0").first # BOOM! >> >> I'm not sure what the significance of 245 or less is. I can inspect >> 'buf', copy and paste it to a separate editor as a string and run ops on >> it with no problem, so I'm very curious as to what's making Ruby segfault. >> > I'm very curious too. > > Your sample code don't segfault. > But I came across segfaults several times in modifing create_junction method. > It's behaviour is very unstable, as I insert p method,it sometimes runs OK. > It's location was mainly split method or get_last_error method. > > I guess it's not related with 245 or 260, but it seems to underlying C > pointer memory access failure problem. > Can you give me a sample stable segfault generating code? To add even more mystery to this problem, that code isn't segfaulting for me at the moment, though it was regularly last night (I still have the console window open that shows the segfaults to prove it to myself). I saw the same behavior you mentioned - inserting a 'puts' would sometimes cause code that was previously segfaulting to suddenly work. Well, let's put the Unicode stuff on hold for now. Perhaps deep inspection of string.c some day will reveal what the potential problem is. Many thanks, Dan From phasis at gmail.com Sun May 28 22:20:14 2006 From: phasis at gmail.com (Heesob Park) Date: Mon, 29 May 2006 11:20:14 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <4479A828.6030005@gmail.com> References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> Message-ID: Hi, 2006/5/28, Daniel Berger : > Heesob Park wrote: > > Hi, > > > > 2006/5/28, Daniel Berger : > >> Heesob Park wrote: > >>> Hi, > > > >> Thanks Heesob, but I'm getting some weird segfaults with wide character > >> functions and buffers over 245 characters. I posted about this to > >> ruby-talk as well. Here's some sample code that demonstrates the problem: > >> > >> require 'Win32API' > >> > >> GetFullPathNameW = Win32API.new('kernel32', 'GetFullPathNameW', 'PLPP', 'L') > >> > >> path = "C:\\test" > >> buf = 0.chr * 260 # 245 or less works ok > >> > >> if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 > >> puts "Failed" > >> exit > >> end > >> > >> p buf.split("\0\0").first # BOOM! > >> > >> I'm not sure what the significance of 245 or less is. I can inspect > >> 'buf', copy and paste it to a separate editor as a string and run ops on > >> it with no problem, so I'm very curious as to what's making Ruby segfault. > >> > > I'm very curious too. > > > > Your sample code don't segfault. > > But I came across segfaults several times in modifing create_junction method. > > It's behaviour is very unstable, as I insert p method,it sometimes runs OK. > > It's location was mainly split method or get_last_error method. > > > > I guess it's not related with 245 or 260, but it seems to underlying C > > pointer memory access failure problem. > > Can you give me a sample stable segfault generating code? > > To add even more mystery to this problem, that code isn't segfaulting > for me at the moment, though it was regularly last night (I still have > the console window open that shows the segfaults to prove it to myself). > > I saw the same behavior you mentioned - inserting a 'puts' would > sometimes cause code that was previously segfaulting to suddenly work. > > Well, let's put the Unicode stuff on hold for now. Perhaps deep > inspection of string.c some day will reveal what the potential problem is. > I have found out what is the problem. It's not bug of Ruby or Windows, it is only bug of code. First try this: require 'Win32API' GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') for i in 1..100 path = "c:\\test" buf = 0.chr * 260 if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 puts "Failed" end p buf.split("\0\0").first end It will cause various errors like uninitialized constant GetFullPathNameW (NameError) or segfault. Next, try this: require 'Win32API' GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') for i in 1..100 path = "c:\\test" buf = 0.chr * 260 # buf.size/2 -> actual length of buf if GetFullPathNameW.call(path, buf.size/2, buf, 0) == 0 puts "Failed" end p buf.split("\0\0").first end It runs Ok. but the result is not correct. Next , try this: require 'Win32API' GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') for i in 1..100 # append \0 to path path = "c:\\test\0" buf = 0.chr * 260 # buf.size/2 -> actual length of buf in unicode string if GetFullPathNameW.call(path, buf.size/2, buf, 0) == 0 puts "Failed" end p buf.split("\0\0").first end It runs ok. The result is correct. Finally, the complete and correct code is like this: require 'Win32API' GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') for i in 1..100 path = "c\0:\0\\\0t\0e\0s\0t\0\0" buf = 0.chr * 260 # buf.size/2 -> actual length of buf in unicode string if GetFullPathNameW.call(path, buf.size/2, buf, 0) == 0 puts "Failed" end buf = buf.split("\0\0").first buf = (buf.size % 2).zero? ? buf : buf+"\0" p buf end Remeber, Ruby's string is terminated with "\0" implicitly, but UTF16 string requires double "\0". For ascii chars, it happens trailing three "\0" : one for ascii char and two for string termination. Regards, Park Heesob From djberg96 at gmail.com Sun May 28 23:03:56 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 28 May 2006 21:03:56 -0600 Subject: [Win32utils-devel] [ANN] win32-eventlog 0.4.0 In-Reply-To: <20060529012704.292EB83EA@mx2.delmonte-phil.com> References: <20060529012704.292EB83EA@mx2.delmonte-phil.com> Message-ID: <447A649C.4010107@gmail.com> Pe?a wrote: > # Ok, fixed and released as 0.4.1. Thanks for the report! > > Hi Dan, > > the new change_notify does not exhibit the resource error anymore. > BUT it skips (and does not log) some records. > > Tail is much better and does not skip. > > kind regards -botp > NotifyChangeEventLog() only checks every five seconds, max, iirc. If an app logs more than one entry in that five second period it's going to be missed I'm afraid. Hm....I suppose I could adapt change_notify to use the same approach that I used for tail. I'll think about it. Thoughts anyone? Thanks, Dan PS - cc'd to the devel mailing list From djberg96 at gmail.com Mon May 29 00:22:36 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 28 May 2006 22:22:36 -0600 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> Message-ID: <447A770C.4080608@gmail.com> Heesob Park wrote: > Hi, > > 2006/5/28, Daniel Berger : >> Heesob Park wrote: >>> Hi, >>> >>> 2006/5/28, Daniel Berger : >>>> Heesob Park wrote: >>>>> Hi, >>> >>>> Thanks Heesob, but I'm getting some weird segfaults with wide character >>>> functions and buffers over 245 characters. I posted about this to >>>> ruby-talk as well. Here's some sample code that demonstrates the problem: >>>> >>>> require 'Win32API' >>>> >>>> GetFullPathNameW = Win32API.new('kernel32', 'GetFullPathNameW', 'PLPP', 'L') >>>> >>>> path = "C:\\test" >>>> buf = 0.chr * 260 # 245 or less works ok >>>> >>>> if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 >>>> puts "Failed" >>>> exit >>>> end >>>> >>>> p buf.split("\0\0").first # BOOM! >>>> >>>> I'm not sure what the significance of 245 or less is. I can inspect >>>> 'buf', copy and paste it to a separate editor as a string and run ops on >>>> it with no problem, so I'm very curious as to what's making Ruby segfault. >>>> >>> I'm very curious too. >>> >>> Your sample code don't segfault. >>> But I came across segfaults several times in modifing create_junction method. >>> It's behaviour is very unstable, as I insert p method,it sometimes runs OK. >>> It's location was mainly split method or get_last_error method. >>> >>> I guess it's not related with 245 or 260, but it seems to underlying C >>> pointer memory access failure problem. >>> Can you give me a sample stable segfault generating code? >> To add even more mystery to this problem, that code isn't segfaulting >> for me at the moment, though it was regularly last night (I still have >> the console window open that shows the segfaults to prove it to myself). >> >> I saw the same behavior you mentioned - inserting a 'puts' would >> sometimes cause code that was previously segfaulting to suddenly work. >> >> Well, let's put the Unicode stuff on hold for now. Perhaps deep >> inspection of string.c some day will reveal what the potential problem is. >> > I have found out what is the problem. > It's not bug of Ruby or Windows, it is only bug of code. > > First try this: > > require 'Win32API' > GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') > for i in 1..100 > path = "c:\\test" > buf = 0.chr * 260 > if GetFullPathNameW.call(path, buf.size, buf, 0) == 0 > puts "Failed" > end > p buf.split("\0\0").first > end > > It will cause various errors like > uninitialized constant GetFullPathNameW (NameError) > or > segfault. > > Next, try this: > > require 'Win32API' > GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') > for i in 1..100 > path = "c:\\test" > buf = 0.chr * 260 > # buf.size/2 -> actual length of buf > if GetFullPathNameW.call(path, buf.size/2, buf, 0) == 0 > puts "Failed" > end > p buf.split("\0\0").first > end > > It runs Ok. but the result is not correct. > > Next , try this: > > require 'Win32API' > GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') > for i in 1..100 > # append \0 to path > path = "c:\\test\0" > buf = 0.chr * 260 > # buf.size/2 -> actual length of buf in unicode string > if GetFullPathNameW.call(path, buf.size/2, buf, 0) == 0 > puts "Failed" > end > p buf.split("\0\0").first > end > > It runs ok. The result is correct. > > Finally, the complete and correct code is like this: > > require 'Win32API' > GetFullPathNameW = Win32API.new('kernel32','GetFullPathNameW','PLPP', 'L') > for i in 1..100 > path = "c\0:\0\\\0t\0e\0s\0t\0\0" > buf = 0.chr * 260 > # buf.size/2 -> actual length of buf in unicode string > if GetFullPathNameW.call(path, buf.size/2, buf, 0) == 0 > puts "Failed" > end > buf = buf.split("\0\0").first > buf = (buf.size % 2).zero? ? buf : buf+"\0" > p buf > end > > Remeber, Ruby's string is terminated with "\0" implicitly, but UTF16 > string requires double "\0". > For ascii chars, it happens trailing three "\0" : one for ascii char > and two for string termination. > > Regards, > > Park Heesob While I understand why this code works, I'm still not entirely clear why the previous code would cause the interpreter to segfault. Bad pointer address? In any case, excellent work, thank you! Now I'm trying to work out a general approach for the windows-pr stuff. Given a method like this: def GetFullPathName(file, buf, buf_size, part) if $KCODE != 'NONE' GetFullPathNameW.call(file, buf, buf_size, part) else GetFullPathName.call(file, buf, buf_size, part) end end Should I modify it to try to do a best-guess? if $KCODE != 'NONE' GetFullPathNameW.call(file, buf, buf_size/2, part) end Or do you think that's the user's job? Thanks, Dan From phasis at gmail.com Mon May 29 00:50:34 2006 From: phasis at gmail.com (Heesob Park) Date: Mon, 29 May 2006 13:50:34 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <447A770C.4080608@gmail.com> References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> <447A770C.4080608@gmail.com> Message-ID: Hi, 2006/5/29, Daniel Berger : > While I understand why this code works, I'm still not entirely clear why > the previous code would cause the interpreter to segfault. Bad pointer > address? > Yes, Ruby's string is not just character array, it is actually a structure and a tainted structure causes unexpected behaviour. > In any case, excellent work, thank you! > You are welcome. > Now I'm trying to work out a general approach for the windows-pr stuff. > Given a method like this: > > def GetFullPathName(file, buf, buf_size, part) > if $KCODE != 'NONE' > GetFullPathNameW.call(file, buf, buf_size, part) > else > GetFullPathName.call(file, buf, buf_size, part) > end > end > > Should I modify it to try to do a best-guess? > > if $KCODE != 'NONE' > GetFullPathNameW.call(file, buf, buf_size/2, part) > end > Be careful, before calling GetFullPathNameW, the "file" must be UTF16 string. I recommend all function call using W function, and if string is not UTF16 then first convert it to UTF16 string. $KCODE must be used to only determine the string is UTF8 string, not determine to call wheter Ansi function or W function. Because Ruby interpreter cannot handle UTF16 code file, the user has no chance to use UTF16 string in real world in the ruby code. Sample code is like this: from = multi_to_wide(from) to = multi_to_wide(to) if GetFullPathNameW.call(from, from_path.size, from_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error end if GetFullPathNameW.call(to, to_path.size, to_path, 0) == 0 raise StandardError, 'GetFullPathName() failed: ' + get_last_error end > Or do you think that's the user's job? > I think the user would'nt care about file name is unicode or ansi string. Regards, Park Heesob From djberg96 at gmail.com Mon May 29 01:04:27 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Sun, 28 May 2006 23:04:27 -0600 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> <447A770C.4080608@gmail.com> Message-ID: <447A80DB.3010601@gmail.com> Heesob Park wrote: > Hi, > > 2006/5/29, Daniel Berger : > >> While I understand why this code works, I'm still not entirely clear why >> the previous code would cause the interpreter to segfault. Bad pointer >> address? >> > Yes, Ruby's string is not just character array, it is actually a > structure and a tainted structure causes unexpected behaviour. Ah, right. > >> In any case, excellent work, thank you! >> > You are welcome. > >> Now I'm trying to work out a general approach for the windows-pr stuff. >> Given a method like this: >> >> def GetFullPathName(file, buf, buf_size, part) >> if $KCODE != 'NONE' >> GetFullPathNameW.call(file, buf, buf_size, part) >> else >> GetFullPathName.call(file, buf, buf_size, part) >> end >> end >> >> Should I modify it to try to do a best-guess? >> >> if $KCODE != 'NONE' >> GetFullPathNameW.call(file, buf, buf_size/2, part) >> end >> > > Be careful, before calling GetFullPathNameW, the "file" must be UTF16 string. > I recommend all function call using W function, and if string is not > UTF16 then first convert it to UTF16 string. > $KCODE must be used to only determine the string is UTF8 string, not > determine to call wheter Ansi function or W function. What would you recommend then? How should I determine within Ruby if the string being passed to a function is UTF16? IsTextUnicode()? Something else? How would you define GetFullPathName within file.rb (from windows-pr) then, for example? Thanks, Dan From phasis at gmail.com Mon May 29 01:29:00 2006 From: phasis at gmail.com (Heesob Park) Date: Mon, 29 May 2006 14:29:00 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <447A80DB.3010601@gmail.com> References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> <447A770C.4080608@gmail.com> <447A80DB.3010601@gmail.com> Message-ID: 2006/5/29, Daniel Berger : > Heesob Park wrote: > > Hi, > > > > 2006/5/29, Daniel Berger : > > > >> While I understand why this code works, I'm still not entirely clear why > >> the previous code would cause the interpreter to segfault. Bad pointer > >> address? > >> > > Yes, Ruby's string is not just character array, it is actually a > > structure and a tainted structure causes unexpected behaviour. > > Ah, right. > > > > >> In any case, excellent work, thank you! > >> > > You are welcome. > > > >> Now I'm trying to work out a general approach for the windows-pr stuff. > >> Given a method like this: > >> > >> def GetFullPathName(file, buf, buf_size, part) > >> if $KCODE != 'NONE' > >> GetFullPathNameW.call(file, buf, buf_size, part) > >> else > >> GetFullPathName.call(file, buf, buf_size, part) > >> end > >> end > >> > >> Should I modify it to try to do a best-guess? > >> > >> if $KCODE != 'NONE' > >> GetFullPathNameW.call(file, buf, buf_size/2, part) > >> end > >> > > > > Be careful, before calling GetFullPathNameW, the "file" must be UTF16 string. > > I recommend all function call using W function, and if string is not > > UTF16 then first convert it to UTF16 string. > > $KCODE must be used to only determine the string is UTF8 string, not > > determine to call wheter Ansi function or W function. > > What would you recommend then? How should I determine within Ruby if > the string being passed to a function is UTF16? IsTextUnicode()? > Something else? > The user might not call function with UTF16 by accident. But the user who want call function with UTF16 string on purpose, use utf16 flag. > How would you define GetFullPathName within file.rb (from windows-pr) > then, for example? > How about this? def GetFullPathName(file, buf_size, buf, part, utf16 = false) file = multi_to_wide(file) unless utf16 GetFullPathNameW.call(file, buf.size/2, buf, part) end Regards, Park Heesob From djberg96 at gmail.com Mon May 29 03:19:16 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 29 May 2006 01:19:16 -0600 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: References: <447683A1.3030009@gmail.com> <4477532E.9020709@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> <447A770C.4080608@gmail.com> <447A80DB.3010601@gmail.com> Message-ID: <447AA074.20307@gmail.com> Heesob Park wrote: > How about this? > > def GetFullPathName(file, buf_size, buf, part, utf16 = false) > file = multi_to_wide(file) unless utf16 > GetFullPathNameW.call(file, buf.size/2, buf, part) > end Except that means adding an extra argument to a lot of methods. Hm....what about: def GetFullPathName(file, buf_size, buf, part) file = multi_to_wide(file) unless IsTextUnicode(file) GetFullPathNameW.call(file, buf.size/2, buf, part) end A little more work for me, but less for the user to remember. Will that work? Or do you think IsTextUnicode() is too unreliable? (Sorry if you answered this previously) Regards, Dan From phasis at gmail.com Mon May 29 03:53:04 2006 From: phasis at gmail.com (Heesob Park) Date: Mon, 29 May 2006 16:53:04 +0900 Subject: [Win32utils-devel] win32-dir, unicode In-Reply-To: <447AA074.20307@gmail.com> References: <447683A1.3030009@gmail.com> <44793410.8060304@gmail.com> <4479A828.6030005@gmail.com> <447A770C.4080608@gmail.com> <447A80DB.3010601@gmail.com> <447AA074.20307@gmail.com> Message-ID: Hi, 2006/5/29, Daniel Berger : > Heesob Park wrote: > > > > > How about this? > > > > def GetFullPathName(file, buf_size, buf, part, utf16 = false) > > file = multi_to_wide(file) unless utf16 > > GetFullPathNameW.call(file, buf.size/2, buf, part) > > end > > Except that means adding an extra argument to a lot of methods. > > Hm....what about: > > def GetFullPathName(file, buf_size, buf, part) > file = multi_to_wide(file) unless IsTextUnicode(file) > GetFullPathNameW.call(file, buf.size/2, buf, part) > end > > A little more work for me, but less for the user to remember. > That's Ok for internal Use. But what if the user wants the result of the function ? Every function needs to be a->w;callw;w->a; conversion like this? def GetFullPathName(file, buf_size, buf, part) file = multi_to_wide(file) unless IsTextUnicode(file) GetFullPathNameW.call(file, buf.size/2, buf, part) buf = wide_to_multi(buf) end I recommend to separate two functions like this: def GetFullPathName(file, buf_size, buf, part) GetFullPathName.call(file, buf.size/2, buf, part) end def GetFullPathNameW(file, buf_size, buf, part) file = multi_to_wide(file) unless IsTextUnicode(file) GetFullPathNameW.call(file, buf.size/2, buf, part) end > Will that work? Or do you think IsTextUnicode() is too unreliable? > I think it is a useful function. I just don't want to make slow code with using another api function:) Regards, Park Heesob From noreply at rubyforge.org Mon May 29 11:20:21 2006 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 29 May 2006 11:20:21 -0400 Subject: [Win32utils-devel] [ win32utils-Bugs-4598 ] possible wrong condition Message-ID: <200605291520.k4TFKLSa031134@rubyforge.org> Bugs item #4598, was opened at 2006-05-29 11:20 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=4598&group_id=85 Category: win32-eventlog Group: None Status: Open Resolution: None Priority: 3 Submitted By: Nobody (None) Assigned to: Nobody (None) Summary: possible wrong condition Initial Comment: Is this condition right? (eventlog.rb, line 494 if flags | EVENTLOG_SEEK_READ > 0 offset = buf[8,4].unpack('L').first + 1 end To me it seems that it is always true as E_S_R == 2. Maybe this is how it was meant: unless flags & EVENTLOG_SEEK_READ > 0 I haven't understood the rest of the code, so I'm not sure about the solution. Jano Svitok ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=4598&group_id=85 From noreply at rubyforge.org Mon May 29 13:38:58 2006 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 29 May 2006 10:38:58 -0700 Subject: [Win32utils-devel] [ win32utils-Bugs-4598 ] possible wrong condition Message-ID: <200605291738.k4THcwv5031567@rubyforge.org> Bugs item #4598, was opened at 2006-05-29 08:20 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=4598&group_id=85 Category: win32-eventlog Group: None Status: Open >Resolution: Accepted Priority: 3 Submitted By: Nobody (None) >Assigned to: Daniel Berger (djberg96) Summary: possible wrong condition Initial Comment: Is this condition right? (eventlog.rb, line 494 if flags | EVENTLOG_SEEK_READ > 0 offset = buf[8,4].unpack('L').first + 1 end To me it seems that it is always true as E_S_R == 2. Maybe this is how it was meant: unless flags & EVENTLOG_SEEK_READ > 0 I haven't understood the rest of the code, so I'm not sure about the solution. Jano Svitok ---------------------------------------------------------------------- >Comment By: Daniel Berger (djberg96) Date: 2006-05-29 10:38 Message: Not only is the code wrong, some testing revealed that code was the source of another bug. Specifically, a seek + backwards read would loop infinitely. I believe this is the proper code: if flags & EVENTLOG_SEEK_READ > 0 if flags & EVENTLOG_FORWARDS_READ > 0 offset = buf[8,4].unpack('L').first + 1 else offset = buf[8,4].unpack('L').first - 1 end end I'll add some more tests for this. Many thanks for the report! - Dan ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=4598&group_id=85 From noreply at rubyforge.org Mon May 29 17:07:18 2006 From: noreply at rubyforge.org (noreply at rubyforge.org) Date: Mon, 29 May 2006 16:07:18 -0500 Subject: [Win32utils-devel] [ win32utils-Patches-4603 ] [open3] set $? and return Process::Status with block call Message-ID: <200605292107.k4TL7IdR019372@rubyforge.org> Patches item #4603, was opened at 2006-05-29 16:07 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=413&aid=4603&group_id=85 Category: win32-open3 Group: Bug Fix Status: Open Resolution: None Priority: 3 Submitted By: John-Mason Shackelford (jpshackelford) Assigned to: Nobody (None) Summary: [open3] set $? and return Process::Status with block call Initial Comment: This is another version Samuel Tesla's patch which sets $? and also returns the Process::Status when popen3/4 is called with a block (i.e. this patch merges changes from the two patches Samuel submitted). Note that this implementation is not thread-safe. As the attachment will demonstrate. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=413&aid=4603&group_id=85 From jpshack at gmail.com Mon May 29 17:24:00 2006 From: jpshack at gmail.com (John-Mason P. Shackelford) Date: Mon, 29 May 2006 16:24:00 -0500 Subject: [Win32utils-devel] [open3] Exit Status Patch Message-ID: <83f770ff0605291424s2991bfd0v195fcf2f9362d6af@mail.gmail.com> I've added another patch for the popen3 library which sets $? and adds Process::Status a return when popen3/4 is called with a block thus making it closer to the Open4. This is a merge of a couple of patches previously submitted by Samuel Tesla. http://rubyforge.org/tracker/index.php?func=detail&aid=4603&group_id=85&atid=413 Note that this implementation is not thread-safe (as is demonstrated by sample code I've provided.) I'd be very interested in seeing a tweak that would make this thread-safe if anyone has ideas about how to do that. I'd also be grateful for a release which includes this patch (or something better) and that would be compatible with the latest one-click installer. Thanks to all for contributing and maintaining this valuable library. -- John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford at pearson.com http://pearsonedmeasurement.com From djberg96 at gmail.com Mon May 29 23:25:07 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Mon, 29 May 2006 21:25:07 -0600 Subject: [Win32utils-devel] seg on windows-pr-0.5.1 (was RE: [ANN] win32-eventlog 0.4.0) In-Reply-To: <20060530030604.6F2A58305@mx1.delmonte-phil.com> References: <20060530030604.6F2A58305@mx1.delmonte-phil.com> Message-ID: <447BBB13.9060202@gmail.com> Pe?a wrote: > Hi Dan, > i get a segfault on windows-pr if i run mulitple tails by threading, one thread for each host i'm tailing. > > C:\family\ruby\win-eventlog>dtail.rb > thread/tail-ing Security on host1 > thread/tail-ing Security on host2 > thread/tail-ing Security on host3 > thread/tail-ing Security on host4 > thread/tail-ing Security on host5 > thread/tail-ing Security on host6 > c:/ruby/lib/ruby/gems/1.8/gems/windows-pr-0.5.1-mswin32/lib/windows/error.rb:295: [BUG] Segmentation fault > ruby 1.8.4 (2005-12-24) [i386-mswin32] > C:\family\ruby\win-eventlog> > > my code looks like, > > #--- > threads = [] > while x = DATA.gets do > eventlog,host = x.split > printf "thread/tail-ing %s on %s\n",eventlog,host > threads << Thread.new(eventlog,host) do |log,host| > tail_log log,host > end > #tail_log eventlog, host > end > threads.each {|t| t.join} > #--- > > is tail thread-safe or do i need to run it separately for each host for the mean time? Wow, I never imagined folks running a series of eventlogs in different threads. Anyone have any ideas on this? Dan From phasis at gmail.com Mon May 29 23:59:39 2006 From: phasis at gmail.com (Heesob Park) Date: Tue, 30 May 2006 12:59:39 +0900 Subject: [Win32utils-devel] seg on windows-pr-0.5.1 (was RE: [ANN] win32-eventlog 0.4.0) In-Reply-To: <447BBB13.9060202@gmail.com> References: <20060530030604.6F2A58305@mx1.delmonte-phil.com> <447BBB13.9060202@gmail.com> Message-ID: Hi, 2006/5/30, Daniel Berger : > Pe?a wrote: > > Hi Dan, > > i get a segfault on windows-pr if i run mulitple tails by threading, one thread for each host i'm tailing. > > > > C:\family\ruby\win-eventlog>dtail.rb > > thread/tail-ing Security on host1 > > thread/tail-ing Security on host2 > > thread/tail-ing Security on host3 > > thread/tail-ing Security on host4 > > thread/tail-ing Security on host5 > > thread/tail-ing Security on host6 > > c:/ruby/lib/ruby/gems/1.8/gems/windows-pr-0.5.1-mswin32/lib/windows/error.rb:295: [BUG] Segmentation fault > > ruby 1.8.4 (2005-12-24) [i386-mswin32] > > C:\family\ruby\win-eventlog> > > > > my code looks like, > > > > #--- > > threads = [] > > while x = DATA.gets do > > eventlog,host = x.split > > printf "thread/tail-ing %s on %s\n",eventlog,host > > threads << Thread.new(eventlog,host) do |log,host| > > tail_log log,host > > end > > #tail_log eventlog, host > > end > > threads.each {|t| t.join} > > #--- > > > > is tail thread-safe or do i need to run it separately for each host for the mean time? > > Wow, I never imagined folks running a series of eventlogs in different > threads. > > Anyone have any ideas on this? > > Dan > I guess the code needs something like this for thread-safe: require 'thread' semaphore = Mutex.new semaphore.synchronize { get_last_error } Regards, Park Heesob From jpshack at gmail.com Tue May 30 00:19:58 2006 From: jpshack at gmail.com (John-Mason P. Shackelford) Date: Mon, 29 May 2006 23:19:58 -0500 Subject: [Win32utils-devel] has anyone compiled win32-utils under mingw? Message-ID: <83f770ff0605292119k545d2516n8fb75cda14930d41@mail.gmail.com> Since the 1.8.4 One-click installer is based on VC++ 6.0 which is no longer available, I am looking for alternative ways of building win32-utils so as avoid segfaults. Has anyone used MingGW successfully? When I run ruby extconf.rb from MSYS the resulting make file assumes that I am using VC++. Do I need to build ruby under MinGW first? -- John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford at pearson.com http://pearsonedmeasurement.com From luislavena at gmail.com Tue May 30 00:54:47 2006 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 30 May 2006 01:54:47 -0300 Subject: [Win32utils-devel] has anyone compiled win32-utils under mingw? In-Reply-To: <83f770ff0605292119k545d2516n8fb75cda14930d41@mail.gmail.com> References: <83f770ff0605292119k545d2516n8fb75cda14930d41@mail.gmail.com> Message-ID: <71166b3b0605292154m206a342fs5e63f96344a2a359@mail.gmail.com> On 5/30/06, John-Mason P. Shackelford wrote: > Since the 1.8.4 One-click installer is based on VC++ 6.0 which is no > longer available, I am looking for alternative ways of building > win32-utils so as avoid segfaults. Has anyone used MingGW > successfully? When I run ruby extconf.rb from MSYS the resulting make > file assumes that I am using VC++. Do I need to build ruby under MinGW > first? If Ruby is mswin32 (VC), you need VC to build extensions. Building all with mingw32 will brake existing mswin32 binaries gem you use, so be careful with that. I have VC Toolkit 2003 bundled with platform SDK headers and libs. (14Mb 7zip). I used it to build win32 gems for mongrel (and present no binary compatibility issues with msvcrt). Mail me off the list to send you a link for download. I could not share it due non-distributing lincense of Platform SDK, but peer-to-peer way of sharing is allowed. Regards, -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi From djberg96 at gmail.com Tue May 30 08:44:36 2006 From: djberg96 at gmail.com (Daniel Berger) Date: Tue, 30 May 2006 06:44:36 -0600 Subject: [Win32utils-devel] Syslogging and remote installer (was RE: seg on windows-pr-0.5.1 (was RE: [ANN] win32-eventlog 0.4.0)) In-Reply-To: <20060530095606.5FF9184B0@mx2.delmonte-phil.com> References: <20060530095606.5FF9184B0@mx2.delmonte-phil.com> Message-ID: <447C3E34.1090007@gmail.com> Hi again, Pe?a wrote: > # > i get a segfault on windows-pr if i run mulitple tails by > # threading, one thread for each host i'm tailing. > > argh, this is getting tricky. i'm getting empty records and weird characters too :) > > -------- > record_number : 20983290 > time_generated : Tue May 30 16:15:27 China Standard Time 2006 > time_written : Tue May 30 16:15:27 China Standard Time 2006 > event_id : 642 > event_type : audit_success > category : 7 > description : User Account Changed: > Target Account Name: ztest2 > Target Domain: DMPI > Target Account ID: ? > ??????21-1995071569-205336168-60295696-9240} > Caller User Name: pe?aijm > Caller Domain: DMPI > Caller Logon ID: (0x0,0x16DF9294) > > -------- (cc'd to the devel list) I just noticed the "China Standard Time". Do your event log records contain non-ascii text? If so, I'll have to switch to the wide character version of ReadEventLog() I think. This might also explain the duplicate records you showed me earlier (?). Where are you located, btw? I forgot. Also, regarding the EventLog#notify_change method, I just remembered something. From the MSDN docs: The NotifyChangeEventLog function does not work with remote handles. > troubleshooting in win is terrible, i think i might as well go to the other route, that is, just let a linux syslog do the central processing. I really wanted to avoid the client installation, tsktsk.. anyway > > Dan, do you have a win32 util that sends a log snippet/record to a remote syslog server? I am not familiar w the format and the protocol, so i'm asking.. If there's a way to remotely log to a *nix syslog from Windows, I'm afraid I don't know what it is. Anyone? > Also, do you have a utility that remotely installs a service/program? Agrh, the problem here is installing ruby on the remote nodes... The win32-service package should work. Check it out. Regards, Dan From phasis at gmail.com Tue May 30 09:14:35 2006 From: phasis at gmail.com (Heesob Park) Date: Tue, 30 May 2006 22:14:35 +0900 Subject: [Win32utils-devel] Syslogging and remote installer (was RE: seg on windows-pr-0.5.1 (was RE: [ANN] win32-eventlog 0.4.0)) In-Reply-To: <447C3E34.1090007@gmail.com> References: <20060530095606.5FF9184B0@mx2.delmonte-phil.com> <447C3E34.1090007@gmail.com> Message-ID: Hi, 2006/5/30, Daniel Berger : > Hi again, > > Pe?a wrote: > > # > i get a segfault on windows-pr if i run mulitple tails by > > # threading, one thread for each host i'm tailing. > > > > argh, this is getting tricky. i'm getting empty records and weird characters too :) > > > > -------- > > record_number : 20983290 > > time_generated : Tue May 30 16:15:27 China Standard Time 2006 > > time_written : Tue May 30 16:15:27 China Standard Time 2006 > > event_id : 642 > > event_type : audit_success > > category : 7 > > description : User Account Changed: > > Target Account Name: ztest2 > > Target Domain: DMPI > > Target Account ID: ? > > ??????21-1995071569-205336168-60295696-9240} > > Caller User Name: pe?aijm > > Caller Domain: DMPI > > Caller Logon ID: (0x0,0x16DF9294) > > > > -------- > I guess the event logging Windows machine code page is different from the monitoring machine code page. > (cc'd to the devel list) > > I just noticed the "China Standard Time". Do your event log records > contain non-ascii text? If so, I'll have to switch to the wide > character version of ReadEventLog() I think. This might also explain > the duplicate records you showed me earlier (?). > > Where are you located, btw? I forgot. > > Also, regarding the EventLog#notify_change method, I just remembered > something. From the MSDN docs: The NotifyChangeEventLog function does > not work with remote handles. > > > troubleshooting in win is terrible, i think i might as well go to the other route, that is, just let a linux syslog do the central processing. I really wanted to avoid the client installation, tsktsk.. anyway > > > > Dan, do you have a win32 util that sends a log snippet/record to a remote syslog server? I am not familiar w the format and the protocol, so i'm asking.. > > If there's a way to remotely log to a *nix syslog from Windows, I'm > afraid I don't know what it is. Anyone? > I think the Snare Agent for Windows(http://www.intersectalliance.com/projects/SnareWindows/index.html) might be useful. > > Also, do you have a utility that remotely installs a service/program? Agrh, the problem here is installing ruby on the remote nodes... > If your OS is XP or 2003, you can use the remote desktop connection with sharing disk drive. From Daniel.Berger at qwest.com Wed May 31 10:48:28 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 31 May 2006 09:48:28 -0500 Subject: [Win32utils-devel] Looking for docs on some functions and constants Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E6A6@QTOMAE2K3M01.AD.QINTRA.COM> Hi all, I'm starting to set things up to move win32-open3 towards a pure Ruby solution. I've got a windows-pipe module setup, but now I need to define some of the msvcrt IO functions. However, I can't find documentation on MSDN or my system for the following: FMODE_READABLE FMODE_WRITABLE FMODE_BINMODE MakeOpenFile() io_alloc() A recursive search on my header files didn't reveal anything. Any ideas? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From john-mason at shackelford.org Wed May 31 11:11:40 2006 From: john-mason at shackelford.org (John-Mason P. Shackelford) Date: Wed, 31 May 2006 10:11:40 -0500 Subject: [Win32utils-devel] Looking for docs on some functions and constants In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E6A6@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E6A6@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <83f770ff0605310811v7ce81df9q57b43cc83d8cde80@mail.gmail.com> Daniel, Does this help? http://www.ruby-doc.org/doxygen/1.8.1/rubyio_8h.html -- John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford at pearson.com http://pearsonedmeasurement.com From jpshack at gmail.com Wed May 31 11:13:45 2006 From: jpshack at gmail.com (John-Mason P. Shackelford) Date: Wed, 31 May 2006 10:13:45 -0500 Subject: [Win32utils-devel] Looking for docs on some functions and constants In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E6A6@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E6A6@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <83f770ff0605310813o38705425x133d154858669028@mail.gmail.com> Dan, Does this help? http://www.ruby-doc.org/doxygen/1.8.1/rubyio_8h.html -- John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford at pearson.com http://pearsonedmeasurement.com From Daniel.Berger at qwest.com Wed May 31 11:18:42 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 31 May 2006 10:18:42 -0500 Subject: [Win32utils-devel] Looking for docs on some functions andconstants Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E6A8@QTOMAE2K3M01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > John-Mason P. Shackelford > Sent: Wednesday, May 31, 2006 9:12 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Looking for docs on some > functions andconstants > > > Daniel, > > Does this help? > > http://www.ruby-doc.org/doxygen/1.8.1/rubyio_8h.html Hah! No wonder I didn't see them on MSDN! Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Wed May 31 17:23:48 2006 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 31 May 2006 16:23:48 -0500 Subject: [Win32utils-devel] Getting at MakeOpenFile Message-ID: <39AA6550E5AA554AB1456707D6E5563D0259E6AE@QTOMAE2K3M01.AD.QINTRA.COM> Along the same lines as the last question - how can I get to functions like MakeOpenFile via Win32API? It doesn't seem to be exported by msvcrt-ruby18. Possible? Or am I out of luck? Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From waynev at gmail.com Wed May 31 18:04:40 2006 From: waynev at gmail.com (Wayne Vucenic) Date: Wed, 31 May 2006 15:04:40 -0700 Subject: [Win32utils-devel] Getting at MakeOpenFile In-Reply-To: <39AA6550E5AA554AB1456707D6E5563D0259E6AE@QTOMAE2K3M01.AD.QINTRA.COM> References: <39AA6550E5AA554AB1456707D6E5563D0259E6AE@QTOMAE2K3M01.AD.QINTRA.COM> Message-ID: <88c9ce410605311504l6b19ad2p893bfd4def4c810d@mail.gmail.com> Hi Dan, How's it going? Regarding MakeOpenFile... looking in C:\ruby\lib\ruby\1.8\i386-mswin32\rubyio.h, its defined as a macro: #define MakeOpenFile(obj, fp) do {\ if (RFILE(obj)->fptr) {\ rb_io_close(obj);\ free(RFILE(obj)->fptr);\ RFILE(obj)->fptr = 0;\ }\ fp = 0;\ fp = RFILE(obj)->fptr = ALLOC(OpenFile);\ fp->f = fp->f2 = NULL;\ fp->mode = 0;\ fp->pid = 0;\ fp->lineno = 0;\ fp->path = NULL;\ fp->finalize = 0;\ } while (0) so the only way to access it would be to #include "rubyio.h", which doesn't help much for your pure Ruby solution. Wayne --- Wayne Vucenic No Bugs Software Ruby and C# Agile Contract Programming in Silicon Valley On 5/31/06, Berger, Daniel wrote: > Along the same lines as the last question - how can I get to functions > like MakeOpenFile via Win32API? It doesn't seem to be exported by > msvcrt-ruby18. > > Possible? Or am I out of luck? > > Dan > > > This communication is the property of Qwest and may contain confidential or > privileged information. Unauthorized use of this communication is strictly > prohibited and may be unlawful. If you have received this communication > in error, please immediately notify the sender by reply e-mail and destroy > all copies of the communication and any attachments. > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel >