You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Arlie Davis <ad...@stonestreetone.com> on 2006/02/23 01:26:09 UTC

Diffs for running svnserve as a Win32 service

Ok, here's the first cut of the service implementation.  I welcome feedback,
testing, etc.  Before sending any feedback, though, please read the
instructions below, especially the "Known Issues" section.

Thanks.

-- arlie




Windows Service Support for svnserve
------------------------------------

This patch allows svnserve to run as a Windows service.

This patch was written by Arlie Davis, February 2006.  Please send all
feedback, bugs, etc. to dev@subversion.tigris.org, and to 
adavis@stonestreetone.com.

*** NOTE: This patch is NOT yet ready for prime time!  It still needs
          to be reviewed, tested, etc.

--
Arlie Davis
adavis@stonestreetone.com
arlie@sublinear.org


Installation
------------

For now, no means is provided to install the service.  Windows XP and
Windows 2003 Server provide a command-line tool for installing services.
To create a service for svnserve, invoke SC.EXE like so:

   sc create <name> binpath= "c:\svn\bin\svnserve.exe --service <svn-args>"

where <name> is any service name you want, e.g. "svnserve", and <svn-args>
are the arguments to svnserve, such as --root, --listen-port, etc.

In order for svnserve to run as a Windows service, you MUST specify the
--service argument, and you must NOT specify any other run mode argument,
such as --daemon, --tunnel, --inetd, or any of their short forms.  There
is no short form for --service.

SC has many options; use "sc /?".  The most useful are:

   sc create <name>     create a new service
   sc qc <name>         query config for a service
   sc query <name>      query status
   sc delete <name>     delete any service -- BE CAREFUL!
   sc config <name> ... update service config; same args as sc create
   sc start <name>      start a service (does NOT wait for completion!)
   sc stop <name>       stop a service (does NOT wait for it to stop!)

Note that the command-line syntax for SC is rather odd.  Key/value
pairs are specified as "key= value".  The "key=" part must not have
any spaces, and the "value" part MUST be separated from the "key="
by a space.

If you want to be able to see the command shell, add these arguments 
to the "sc create" command-line:

   type= own type= interact

This sets the "interactive" bit on the service, which allows it to interact
with the local console session.

You can create as many services as you like; there is no restriction on
the number of services, or their names.  I use a prefix, like "svn.foo",
"svn.bar", etc.  Each service runs in a separate process.

Uninstalling
------------

To uninstall a service, stop the service, then delete it.  That's all
there is to it.

Running on Startup
------------------

By default, SC creates the service with the start mode set to "demand"
(manual).  If you want the service to start automatically when the system
boots, add "start= auto" to the command line.  You can change the start
mode for an existing service using "sc config <name> start= auto", or
also by using the Windows GUI interface for managing services.  (Start,
All Programs, Administrative Tools, Services, or just run "services.msc"
from Start/Run or from a command-line.)


Starting and Stopping the Service
---------------------------------

You start and stop the service like any other Windows service.  You can
use the command-line "net start <name>", use the GUI Services interface.


Debugging
---------

Debugging a Windows service can be difficult, because the service runs in
a very different context than a user who is logged in.  By default, services
run in a "null" desktop environment.  They cannot interact with the user
(desktop) in any way, and vice versa.

Also, by default, services run as a special user, called LocalSystem.
LocalSystem is not a "user" in the normal sense; it is an NT security ID
(SID)
that is sort of like root, but different.  LocalSystem typically does NOT
have access to any network shares, even if you use "net use" to connect
to a remote file server.  Again, this is because services run in a different
login session.

Depending on which OS you are running, you may have difficulty attaching
a debugger to a running service process.  Also, if you are having trouble
*starting* a service, then you can't attach to the process early enough to
debug it.

So what's a developer to do?  Well, there are several ways you can debug
services.  First, you'll want to enable "interactive" access for the
service.
This allows the service to interact with the local desktop -- you'll be able
to see the command shell that the service runs in, see console output, etc.
To do this, you can either use the standard Windows Services tool
(services.msc),
or you can do it using sc.exe.

   * With the GUI tool, open the properties page for a service, and go 
     to the "Log On" page.  Select "Local System account", and make sure 
     the "Allow service to interact with desktop" box is checked.
     
   * With SC.EXE, configure the service using the command:
   
         sc <name> config type= own type= interact
     
     Yes, you must specify type= twice, and with exactly the spacing shown.
     
In both cases, you'll need to restart the service.  When you do, if the
service started successfully, you'll see the console window of the service.
By default, it doesn't print anything out.

Next, you'll want to attach a debugger, or configure the service to start
under a debugger.  Attaching a debugger should be straightforward -- just
find the process ID.  But if you need to debug something in the service 
startup path, you'll need to have a debugger attached from the very
beginning.
There are two ways to do this.  

In the first method, you alter the command-line of the service (called the
"binary path").  To do this, use SC.EXE to set the binary path to whatever
debugger you are going to use.  I use the most recent version of WinDbg,
which is excellent, and is available at:

   http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx

For example, this command would configure the service to start under a
debugger:

   sc config <name> binpath= "d:\dbg\windbg.exe -g -G
d:\svn\bin\svnserve.exe
      --root d:\path\root --listen-port 9000"

The entire command must be on a single line, of course, and the binary path
must be in double-quotes.  Also, the spacing MUST be:  binpath= "..."

Substitute whatever debugger you want, with whatever command-line you want,
in place of windbg.exe.  Then start the service (sc start <name>), and the
Service Control Manager should execute the command-line you provided as
the binary path.  Then your debugger should start, and should launch the
svnserve process.




Known Issues
------------

* Source code does not (yet) conform to SVN conventions.  Yes, I plan on
  editing it so that it does.
  
* No management tool (installer, etc.).  For the first revision, this is
  intentional; we just want to get the service functionality tested and
  committed before dealing with installation.

* Right now, I don't know of a way to cleanly stop the svnserve process.
  Instead, the implementation closes the listen socket, which causes the
  main loop to exit.  This isn't as bad as it sounds, and is a LOT better
  than other options (such as terminating a thread).

Re: Diffs for running svnserve as a Win32 service

Posted by Julian Foad <ju...@btopenworld.com>.
Garrett Rooney wrote:
> On 2/22/06, Julian Foad <ju...@btopenworld.com> wrote:
> 
>>[...] I've a nasty feeling I heard some time ago that there might be a
>>problem in a situation like this because of the terms of the license agreement
>>for the development kit you use (API documentation etc.).  [...]
> 
> I'm under the impression that Win32 Services are a pretty pedestrian
> part of the Win32 API, nothing with a weird legal situation there.

Phew!  Glad to hear it.  Maybe it was device drivers or something else that I 
heard about, or maybe nothing.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Steve Williams <st...@kromestudios.com>.
Garrett Rooney wrote:

>On 2/22/06, Julian Foad <ju...@btopenworld.com> wrote:
>
>  
>
>>The second thing, and believe me when I say I'm VERY reluctant to mention it,
>>is to ask what is the legal situation regarding you contributing code that
>>makes use of these Microsoft APIs?  Hopefully it's fine, after all you wrote
>>the code, but I've a nasty feeling I heard some time ago that there might be a
>>problem in a situation like this because of the terms of the license agreement
>>for the development kit you use (API documentation etc.).  Sorry if this is an
>>unwelcome question, but I've noticed the project members are quite keen to make
>>sure things are above board so I'd better ask.
>>    
>>
>
>I'm under the impression that Win32 Services are a pretty pedestrian
>part of the Win32 API, nothing with a weird legal situation there.
>  
>

That other discussion was because the provided code included a sample 
file from Microsoft that included a Microsoft copyright notice.  This 
code that Arlie has provided does not use that sample code that the 
other discussion was centred around.

-- 
Sly



This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/22/06, Julian Foad <ju...@btopenworld.com> wrote:

> The second thing, and believe me when I say I'm VERY reluctant to mention it,
> is to ask what is the legal situation regarding you contributing code that
> makes use of these Microsoft APIs?  Hopefully it's fine, after all you wrote
> the code, but I've a nasty feeling I heard some time ago that there might be a
> problem in a situation like this because of the terms of the license agreement
> for the development kit you use (API documentation etc.).  Sorry if this is an
> unwelcome question, but I've noticed the project members are quite keen to make
> sure things are above board so I'd better ask.

I'm under the impression that Win32 Services are a pretty pedestrian
part of the Win32 API, nothing with a weird legal situation there.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


RE: Diffs for running svnserve as a Win32 service

Posted by Arlie Davis <ad...@stonestreetone.com>.
I've read over hacking.html, but I admit that I haven't internalized it
much.  This is my first contribution to Subversion, and so I expect to learn
a lot about the team's development process.  I'll definitely write up a log
message next time.

Second, I can assure you that the service API is as public as can be.  Many
hundreds of products use these APIs; there are no legal encumbrances at all.
They are as public as, say, creating a window & a button on Windows.  They
are part of the freely-available Windows Platform SDK, as referred to in the
SVN hacking guide, and are described in detail in MSDN, both in the versions
that accompany the various MS VC offerings as well as the free web version
at http://msdn.microsoft.com.

-- arlie


-----Original Message-----
From: Julian Foad [mailto:julianfoad@btopenworld.com] 
Sent: Wednesday, February 22, 2006 9:23 PM
To: Arlie Davis
Cc: dev@subversion.tigris.org
Subject: Re: Diffs for running svnserve as a Win32 service

Arlie Davis wrote:
> Ok, here's the first cut of the service implementation.  I welcome 
> feedback, testing, etc.  Before sending any feedback, though, please 
> read the instructions below, especially the "Known Issues" section.

Thanks.  This isn't my area at all, so just two meta-comments.

At some point it would be good if you could read through the relevant parts
of our "Hacker's Guide to Subversion"
<http://subversion.tigris.org/hacking.html>. 
  The first thing that would be nice to see is a log message
<http://subversion.tigris.org/hacking.html#log-messages>; it doesn't matter
that this version of the patch isn't ready for commit, the log message would
help reviewers to understand the structure and purpose of it and its parts.

The second thing, and believe me when I say I'm VERY reluctant to mention
it, is to ask what is the legal situation regarding you contributing code
that makes use of these Microsoft APIs?  Hopefully it's fine, after all you
wrote the code, but I've a nasty feeling I heard some time ago that there
might be a problem in a situation like this because of the terms of the
license agreement for the development kit you use (API documentation etc.).
Sorry if this is an unwelcome question, but I've noticed the project members
are quite keen to make sure things are above board so I'd better ask.

- Julian



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Julian Foad <ju...@btopenworld.com>.
Arlie Davis wrote:
> Ok, here's the first cut of the service implementation.  I welcome feedback,
> testing, etc.  Before sending any feedback, though, please read the
> instructions below, especially the "Known Issues" section.

Thanks.  This isn't my area at all, so just two meta-comments.

At some point it would be good if you could read through the relevant parts of 
our "Hacker's Guide to Subversion" <http://subversion.tigris.org/hacking.html>. 
  The first thing that would be nice to see is a log message 
<http://subversion.tigris.org/hacking.html#log-messages>; it doesn't matter 
that this version of the patch isn't ready for commit, the log message would 
help reviewers to understand the structure and purpose of it and its parts.

The second thing, and believe me when I say I'm VERY reluctant to mention it, 
is to ask what is the legal situation regarding you contributing code that 
makes use of these Microsoft APIs?  Hopefully it's fine, after all you wrote 
the code, but I've a nasty feeling I heard some time ago that there might be a 
problem in a situation like this because of the terms of the license agreement 
for the development kit you use (API documentation etc.).  Sorry if this is an 
unwelcome question, but I've noticed the project members are quite keen to make 
sure things are above board so I'd better ask.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Ivan Zhakov <ch...@gmail.com>.
On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> > Also better use Apache Portable Runtime API for thread operations
> > and might for closing sockets (apr_socket_close as HTTPD does).
>
> Ok, this is two different issues.  First, threads: I looked at using
> APR threads, but there is actually nothing to be gained from doing so.
> The one thread that gets created runs for a very short period of time,
> and does not use the APR at all.  Using the APR functions for thread
> management doesn't have any benefit (this is already a platform-
> specific piece), and just gets in the way.
Subversion built over APR, so anyway better use APR functions. Even
for platform-specific stuff. Who can garauntee that APR wouldn't add
some significat code in apr_thread_create for pool management? Another
reason to APR: there are much more people know APR and can read code.

>
> Second, the call to closesocket.  The current technique for stopping
> svnserve is not pretty, but I don't see a better way to do it.
> Calling apr_socket_close could actually cause a serious program
> (segmentation fault), because main() (and the functions that it
> calls) would exit the loop and would very likely touch fields within
> the apr_socket_t instance.  If the service dispatcher thread freed
> that memory, by calling apr_socket_close, then main() would be
> touching freed memory.  But by closing the socket handle, we insure
> that this cannot happen -- the worst thing that happens is that
> the socket *handle* (not structure) gets closed twice, which is ok.
I've looked to svnserve and didn't find when it closes socket on error?


--
Ivan Zhakov

Re: Diffs for running svnserve as a Win32 service

Posted by "D.J. Heap" <dj...@gmail.com>.
On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> Ok, so tell me what you would consider sufficient for this patch.  Again, I
> would LOVE to be able to shut down svnserve cleanly, and I have already
> structured the code around this, so that any future developer that DOES
> provide clean shutdown can see clearly how to integrate it with the service
> support.
>
> So tell me how to do it.
>
> Otherwise, I don't see how this is a rational objection to taking this
> patch.
>


I'm sure you will get more feedback soon -- as you've probably noticed
this project tends to have a high bar for code submissions.  Large
patches are rarely applied with less than 2 or 3 iterations so don't
be offended -- it's just the way things work here.  It is frustrating
sometimes, but IMO it has helped significantly in keeping a large
project like this reasonably maintainable and approachable.

Also, there are fewer Win32 developers on Subversion, so Win32
specific stuff tends to take longer on feedback, reviews, commiting,
etc.  Please hang in there and be patient.

Thanks!

DJ

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


RE: Diffs for running svnserve as a Win32 service

Posted by Arlie Davis <ad...@stonestreetone.com>.
Do you believe this work is a prerequisite to accepting the Win32 service
patch?

-- arlie
 

-----Original Message-----
From: rooneg@gmail.com [mailto:rooneg@gmail.com] On Behalf Of Garrett Rooney
Sent: Friday, February 24, 2006 5:14 PM
To: Arlie Davis
Cc: Ivan Zhakov; dev@subversion.tigris.org
Subject: Re: Diffs for running svnserve as a Win32 service

On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> Ok, so tell me what you would consider sufficient for this patch.  
> Again, I would LOVE to be able to shut down svnserve cleanly, and I 
> have already structured the code around this, so that any future 
> developer that DOES provide clean shutdown can see clearly how to 
> integrate it with the service support.
>
> So tell me how to do it.

Off the top of my head, the apr_socket_accept needs to be changed to a
poll/accept system, where you poll to see if there's anything to accept,
then accept.  The poll should have a timeout so that when you finish polling
you can check to see if we have been told to shut down.
 The actual shutdown command would come from a signal handler or something
like that.

-garrett



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> Ok, so tell me what you would consider sufficient for this patch.  Again, I
> would LOVE to be able to shut down svnserve cleanly, and I have already
> structured the code around this, so that any future developer that DOES
> provide clean shutdown can see clearly how to integrate it with the service
> support.
>
> So tell me how to do it.

Off the top of my head, the apr_socket_accept needs to be changed to a
poll/accept system, where you poll to see if there's anything to
accept, then accept.  The poll should have a timeout so that when you
finish polling you can check to see if we have been told to shut down.
 The actual shutdown command would come from a signal handler or
something like that.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Diffs for running svnserve as a Win32 service

Posted by Stefan Küng <to...@gmail.com>.
Garrett Rooney wrote:

> All I'm saying is that if the Win32 service code requires the ability
> to shut down svnserve gracefully, then that feature should be added in
> such a way that it can be used on systems other than Win32.  You seem
> to have gone through a great deal of trouble to peek under the covers
> of APR and insert a platform specific hack to make this work, what I
> would prefer would be to avoid the need to do that and just make the
> (maybe fairly small) change to svnserve itself to make it possible to
> shut it down via a signal or something.

Just FYI: it's not just the win32 service code for svnserve that would 
require such a feature. The whole Subversion library should have such a 
feature too, because UI clients must call those API's on a different 
thread (to not block the UI while e.g. checking out a working copy). If 
the user then wants to cancel that operation, UI clients now have to 
rely on the 'cancel' callback Subversion provides. But that isn't called 
too often, and if e.g. a network operation is stuck, that callback isn't 
called until the connection times out (which for the user is way too 
long and makes the whole app appear to hang).

I've tried the apr function apr_pool_cleanup_for_exec(), which *would* 
be the perfect candidate for this (I think):

/* Preparing for exec() --- close files, etc., but *don't* flush I/O
  * buffers, *don't* wait for subprocesses, and *don't* free any memory.
  */
/**
  * Run all of the child_cleanups, so that any unnecessary files are
  * closed because we are about to exec a new program
  */

So that function closes all handles, without freeing the memory. That 
way blocking networking calls would exit, and the library still could do 
a proper cleanup and exit its function.

But: that function is not compiled on Windows and OS2. :(

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Joseph Galbraith <ga...@vandyke.com>.
Arlie Davis wrote:
> Ok, so tell me what you would consider sufficient for this patch.

I believe the suggestion was to try calling
apr_socket_close() and tweak main to not
touch the socket structure if an error is
returned from accept() [except it isn't accept
that main is in, is it... it's select if I
remember correctly.]

I've thought about it, I don't think it will work.

Consider the following scenario: main is just about to call
select, and the service thread calls apr_socket_close().
BOOM!

I don't think there is any good way to synchronize this.

About the only good way I can think of to achieve a clean
shutdown with the current architecture is to set a flag telling
the main loop to exit, and then do something to cause select to
return.

Closing the socket handle is one way to cause select to return;
another way might be to simply connect to ourself.

Thanks,

Joseph


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

RE: Diffs for running svnserve as a Win32 service

Posted by Arlie Davis <ad...@stonestreetone.com>.
Ok, so tell me what you would consider sufficient for this patch.  Again, I
would LOVE to be able to shut down svnserve cleanly, and I have already
structured the code around this, so that any future developer that DOES
provide clean shutdown can see clearly how to integrate it with the service
support.

So tell me how to do it.

Otherwise, I don't see how this is a rational objection to taking this
patch.

-- arlie
 

-----Original Message-----
From: rooneg@gmail.com [mailto:rooneg@gmail.com] On Behalf Of Garrett Rooney
Sent: Friday, February 24, 2006 4:57 PM
To: Arlie Davis
Cc: Ivan Zhakov; dev@subversion.tigris.org
Subject: Re: Diffs for running svnserve as a Win32 service

On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> You are distorting what I said.  Last week, I asked the list for 
> information on cleanly shutting down the service.  I got no responses, 
> and from analyzing the code, there simply *is* no clean way to stop 
> svnserve.  On Unix, SIGQUIT will terminate the process.  On Win32, 
> Control-C will terminate the process.

You got no answer because currently there is no way to do it.

> When I implemented the service support, I had to choose to do 
> *something* with the "stop service" request.  I chose a method that 
> was *more* polite than what the current svnserve implementation.  So 
> I'm a little insulted that you think I'm "bending over backwards to do 
> something the wrong way", since my implementation is marginally 
> *better* than what svnserve does, right now.
>
> I repeat -- if someone can tell me how to *cleanly* shut down 
> svnserve, I will happily add that support to the feature.  The support 
> is already there
> -- the only that is necessary is for svnservice_notify_stop to do 
> something more productive than what I have provided.

All I'm saying is that if the Win32 service code requires the ability to
shut down svnserve gracefully, then that feature should be added in such a
way that it can be used on systems other than Win32.  You seem to have gone
through a great deal of trouble to peek under the covers of APR and insert a
platform specific hack to make this work, what I would prefer would be to
avoid the need to do that and just make the (maybe fairly small) change to
svnserve itself to make it possible to shut it down via a signal or
something.

-garrett



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> You are distorting what I said.  Last week, I asked the list for information
> on cleanly shutting down the service.  I got no responses, and from
> analyzing the code, there simply *is* no clean way to stop svnserve.  On
> Unix, SIGQUIT will terminate the process.  On Win32, Control-C will
> terminate the process.

You got no answer because currently there is no way to do it.

> When I implemented the service support, I had to choose to do *something*
> with the "stop service" request.  I chose a method that was *more* polite
> than what the current svnserve implementation.  So I'm a little insulted
> that you think I'm "bending over backwards to do something the wrong way",
> since my implementation is marginally *better* than what svnserve does,
> right now.
>
> I repeat -- if someone can tell me how to *cleanly* shut down svnserve, I
> will happily add that support to the feature.  The support is already there
> -- the only that is necessary is for svnservice_notify_stop to do something
> more productive than what I have provided.

All I'm saying is that if the Win32 service code requires the ability
to shut down svnserve gracefully, then that feature should be added in
such a way that it can be used on systems other than Win32.  You seem
to have gone through a great deal of trouble to peek under the covers
of APR and insert a platform specific hack to make this work, what I
would prefer would be to avoid the need to do that and just make the
(maybe fairly small) change to svnserve itself to make it possible to
shut it down via a signal or something.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Diffs for running svnserve as a Win32 service

Posted by Tim Hill <ti...@realmsys.com>.
Ok, I'm just a spectator here, but how can anyone accuse Arlie of not 
having a _constructive_ attitude when he's been working hard on adding 
this feature in the first place? What could be more constructive than that?

I, for one, appreciate his work and look forward to using it when available.

--Tim

Garrett Rooney wrote:

>On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
>  
>
>>If someone wants to provide a way to cleanly shut down svnserve, I'm all for
>>it.  But the fact is that svnserve does not currently provide for clean
>>shutdown on *any* platform.  It does not register any signal handlers for
>>SIGQUIT, etc.  So, holding up this patch seems unfair -- I'm providing a
>>feature, not trying to solve problems that existed before I showed up.
>>    
>>
>
>That's not a very constructive attitude.  You're willing to bend over
>backwards to do something the wrong way but not to spend a little time
>investigating a solution that works for everyone?
>
>-garrett
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
>For additional commands, e-mail: dev-help@subversion.tigris.org
>
>
>
>  
>

RE: Diffs for running svnserve as a Win32 service

Posted by Arlie Davis <ad...@stonestreetone.com>.
You are distorting what I said.  Last week, I asked the list for information
on cleanly shutting down the service.  I got no responses, and from
analyzing the code, there simply *is* no clean way to stop svnserve.  On
Unix, SIGQUIT will terminate the process.  On Win32, Control-C will
terminate the process.

When I implemented the service support, I had to choose to do *something*
with the "stop service" request.  I chose a method that was *more* polite
than what the current svnserve implementation.  So I'm a little insulted
that you think I'm "bending over backwards to do something the wrong way",
since my implementation is marginally *better* than what svnserve does,
right now.

I repeat -- if someone can tell me how to *cleanly* shut down svnserve, I
will happily add that support to the feature.  The support is already there
-- the only that is necessary is for svnservice_notify_stop to do something
more productive than what I have provided.

-- arlie

 

-----Original Message-----
From: rooneg@gmail.com [mailto:rooneg@gmail.com] On Behalf Of Garrett Rooney
Sent: Friday, February 24, 2006 4:09 PM
To: Arlie Davis
Cc: Ivan Zhakov; dev@subversion.tigris.org
Subject: Re: Diffs for running svnserve as a Win32 service

On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> If someone wants to provide a way to cleanly shut down svnserve, I'm 
> all for it.  But the fact is that svnserve does not currently provide 
> for clean shutdown on *any* platform.  It does not register any signal 
> handlers for SIGQUIT, etc.  So, holding up this patch seems unfair -- 
> I'm providing a feature, not trying to solve problems that existed before
I showed up.

That's not a very constructive attitude.  You're willing to bend over
backwards to do something the wrong way but not to spend a little time
investigating a solution that works for everyone?

-garrett



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> If someone wants to provide a way to cleanly shut down svnserve, I'm all for
> it.  But the fact is that svnserve does not currently provide for clean
> shutdown on *any* platform.  It does not register any signal handlers for
> SIGQUIT, etc.  So, holding up this patch seems unfair -- I'm providing a
> feature, not trying to solve problems that existed before I showed up.

That's not a very constructive attitude.  You're willing to bend over
backwards to do something the wrong way but not to spend a little time
investigating a solution that works for everyone?

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


RE: Diffs for running svnserve as a Win32 service

Posted by "Peter N. Lundblad" <pe...@famlundblad.se>.
On Fri, 24 Feb 2006, Arlie Davis wrote:

> If someone wants to provide a way to cleanly shut down svnserve, I'm all for
> it.  But the fact is that svnserve does not currently provide for clean
> shutdown on *any* platform.  It does not register any signal handlers for
> SIGQUIT, etc.  So, holding up this patch seems unfair -- I'm providing a
> feature, not trying to solve problems that existed before I showed up.
>
I agree.  I stumbled upon the same problem when I implemented the PID file
support and punted, assuming that the distributors will handle removing
the PID file when stopping (killing) the deamon.

Regards,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

RE: Diffs for running svnserve as a Win32 service

Posted by Arlie Davis <ad...@stonestreetone.com>.
If someone wants to provide a way to cleanly shut down svnserve, I'm all for
it.  But the fact is that svnserve does not currently provide for clean
shutdown on *any* platform.  It does not register any signal handlers for
SIGQUIT, etc.  So, holding up this patch seems unfair -- I'm providing a
feature, not trying to solve problems that existed before I showed up.

-- arlie 


-----Original Message-----
From: rooneg@gmail.com [mailto:rooneg@gmail.com] On Behalf Of Garrett Rooney
Sent: Friday, February 24, 2006 3:49 PM
To: Arlie Davis
Cc: Ivan Zhakov; dev@subversion.tigris.org
Subject: Re: Diffs for running svnserve as a Win32 service

On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:

> Second, the call to closesocket.  The current technique for stopping 
> svnserve is not pretty, but I don't see a better way to do it.
> Calling apr_socket_close could actually cause a serious program 
> (segmentation fault), because main() (and the functions that it
> calls) would exit the loop and would very likely touch fields within 
> the apr_socket_t instance.  If the service dispatcher thread freed 
> that memory, by calling apr_socket_close, then main() would be 
> touching freed memory.  But by closing the socket handle, we insure 
> that this cannot happen -- the worst thing that happens is that the 
> socket *handle* (not structure) gets closed twice, which is ok.

If main is touching fields with the socket after an error is returned from
accept, then that's a bug in main.  If an error isn't returned from accept
when the socket is closed via apr_socket_close, that seems kind of odd to
me, and should be investigated.  Regardless, if you're putting a "clean
shutdown" feature into svnserve it should work on all platforms, not just
Win32.

-garrett



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/24/06, Arlie Davis <ad...@stonestreetone.com> wrote:

> Second, the call to closesocket.  The current technique for stopping
> svnserve is not pretty, but I don't see a better way to do it.
> Calling apr_socket_close could actually cause a serious program
> (segmentation fault), because main() (and the functions that it
> calls) would exit the loop and would very likely touch fields within
> the apr_socket_t instance.  If the service dispatcher thread freed
> that memory, by calling apr_socket_close, then main() would be
> touching freed memory.  But by closing the socket handle, we insure
> that this cannot happen -- the worst thing that happens is that
> the socket *handle* (not structure) gets closed twice, which is ok.

If main is touching fields with the socket after an error is returned
from accept, then that's a bug in main.  If an error isn't returned
from accept when the socket is closed via apr_socket_close, that seems
kind of odd to me, and should be investigated.  Regardless, if you're
putting a "clean shutdown" feature into svnserve it should work on all
platforms, not just Win32.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


RE: Diffs for running svnserve as a Win32 service

Posted by Arlie Davis <ad...@stonestreetone.com>.
> There are already implemented svn_error_wrap_apr(), 
> apr_get_os_errro() and APR_FROM_OS_ERROR which is 
> better than home-bred svn_error_create_win32()/get_win32_error_text() 

I've converted my code to use this.  Thanks.

> Also better use Apache Portable Runtime API for thread operations 
> and might for closing sockets (apr_socket_close as HTTPD does).

Ok, this is two different issues.  First, threads: I looked at using
APR threads, but there is actually nothing to be gained from doing so.
The one thread that gets created runs for a very short period of time,
and does not use the APR at all.  Using the APR functions for thread
management doesn't have any benefit (this is already a platform-
specific piece), and just gets in the way.

Second, the call to closesocket.  The current technique for stopping
svnserve is not pretty, but I don't see a better way to do it.
Calling apr_socket_close could actually cause a serious program
(segmentation fault), because main() (and the functions that it
calls) would exit the loop and would very likely touch fields within
the apr_socket_t instance.  If the service dispatcher thread freed
that memory, by calling apr_socket_close, then main() would be
touching freed memory.  But by closing the socket handle, we insure
that this cannot happen -- the worst thing that happens is that
the socket *handle* (not structure) gets closed twice, which is ok.

After this post, I'm going to submit a patch for the feature.

Thanks all.

-- arlie



-----Original Message-----
From: Ivan Zhakov [mailto:chemodax@gmail.com] 
Sent: Friday, February 24, 2006 1:16 PM
To: Arlie Davis
Cc: dev@subversion.tigris.org
Subject: Re: Diffs for running svnserve as a Win32 service

On 2/23/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> Ok, here's the first cut of the service implementation.  I welcome 
> feedback, testing, etc.  Before sending any feedback, though, please 
> read the instructions below, especially the "Known Issues" section.
>
First of all, please provide log message as hacking.html states.

I closely look to you patch latter. But there are several things that I
mentioned while quick look through:
There are already implemented svn_error_wrap_apr(), apr_get_os_errro() and
APR_FROM_OS_ERROR which is better than home-bred
svn_error_create_win32()/get_win32_error_text()
Also better use Apache Portable Runtime API for thread operations and might
for closing sockets (apr_socket_close as HTTPD does). Look to APR
documentation: http://apr.apache.org/docs/apr/

--
Ivan Zhakov



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Diffs for running svnserve as a Win32 service

Posted by Ivan Zhakov <ch...@gmail.com>.
On 2/23/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> Ok, here's the first cut of the service implementation.  I welcome feedback,
> testing, etc.  Before sending any feedback, though, please read the
> instructions below, especially the "Known Issues" section.
>
First of all, please provide log message as hacking.html states.

I closely look to you patch latter. But there are several things that
I mentioned while quick look through:
There are already implemented svn_error_wrap_apr(), apr_get_os_errro()
and APR_FROM_OS_ERROR which is better than home-bred
svn_error_create_win32()/get_win32_error_text()
Also better use Apache Portable Runtime API for thread operations and
might for closing sockets (apr_socket_close as HTTPD does). Look to
APR documentation: http://apr.apache.org/docs/apr/

--
Ivan Zhakov

Re: Diffs for running svnserve as a Win32 service

Posted by Ivan Zhakov <ch...@gmail.com>.
On 2/23/06, D.J. Heap <dj...@gmail.com> wrote:
> On 2/22/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> > Ok, here's the first cut of the service implementation.  I welcome feedback,
> > testing, etc.  Before sending any feedback, though, please read the
> > instructions below, especially the "Known Issues" section.
> >
> [snip]
> >
> > * Right now, I don't know of a way to cleanly stop the svnserve process.
> >   Instead, the implementation closes the listen socket, which causes the
> >   main loop to exit.  This isn't as bad as it sounds, and is a LOT better
> >   than other options (such as terminating a thread).
>
>
> This will be very handy, thanks!  I built and played with it a bit and
> it worked very well.
>
> Can the ra_dav experts explain how mod_dav_svn handles it when Apache
> is shut down?  Such as if a big commit was in progress to a BDB
> backend?
IIRC apache with mpm_worker closes tcp socket. With mpm_fork it simply
kills processes. So, I consider better way is close tcp socket in
svnserve service.

--
Ivan Zhakov

Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/22/06, D.J. Heap <dj...@gmail.com> wrote:
> On 2/22/06, Garrett Rooney <ro...@electricjellyfish.net> wrote:
> > On 2/22/06, D.J. Heap <dj...@gmail.com> wrote:
> >
> > > Can the ra_dav experts explain how mod_dav_svn handles it when Apache
> > > is shut down?  Such as if a big commit was in progress to a BDB
> > > backend?
> >
> > Depends on how you shut it down.  A graceful shutdown will have apache
> > wait until in-progress connections are closed, a regular shutdown will
> > eventually kill off worker processes if they don't exit reasonably
> > quickly.
> >
>
> So mod_dav_svn doesn't handle any special signals or try to clean up
> and get out early if an unfinished commit is in progress?

Not that I'm aware of.  It's hard to do things like that in apache
because you don't know if you're in an environment that will let you
set up a signal handler.  Signal handlers are global, you could be in
a multithreaded MPM, etc.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Diffs for running svnserve as a Win32 service

Posted by "D.J. Heap" <dj...@gmail.com>.
On 2/22/06, Garrett Rooney <ro...@electricjellyfish.net> wrote:
> On 2/22/06, D.J. Heap <dj...@gmail.com> wrote:
>
> > Can the ra_dav experts explain how mod_dav_svn handles it when Apache
> > is shut down?  Such as if a big commit was in progress to a BDB
> > backend?
>
> Depends on how you shut it down.  A graceful shutdown will have apache
> wait until in-progress connections are closed, a regular shutdown will
> eventually kill off worker processes if they don't exit reasonably
> quickly.
>

So mod_dav_svn doesn't handle any special signals or try to clean up
and get out early if an unfinished commit is in progress?

DJ

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Diffs for running svnserve as a Win32 service

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 2/22/06, D.J. Heap <dj...@gmail.com> wrote:

> Can the ra_dav experts explain how mod_dav_svn handles it when Apache
> is shut down?  Such as if a big commit was in progress to a BDB
> backend?

Depends on how you shut it down.  A graceful shutdown will have apache
wait until in-progress connections are closed, a regular shutdown will
eventually kill off worker processes if they don't exit reasonably
quickly.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Diffs for running svnserve as a Win32 service

Posted by "D.J. Heap" <dj...@gmail.com>.
On 2/22/06, Arlie Davis <ad...@stonestreetone.com> wrote:
> Ok, here's the first cut of the service implementation.  I welcome feedback,
> testing, etc.  Before sending any feedback, though, please read the
> instructions below, especially the "Known Issues" section.
>
[snip]
>
> * Right now, I don't know of a way to cleanly stop the svnserve process.
>   Instead, the implementation closes the listen socket, which causes the
>   main loop to exit.  This isn't as bad as it sounds, and is a LOT better
>   than other options (such as terminating a thread).


This will be very handy, thanks!  I built and played with it a bit and
it worked very well.

Can the ra_dav experts explain how mod_dav_svn handles it when Apache
is shut down?  Such as if a big commit was in progress to a BDB
backend?

DJ

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org