Re: [naviserver-devel] nsdbpg SSL mode

2013-12-05 Thread Stephen Deasey
On Thu, Dec 5, 2013 at 11:44 PM, Ian Harding  wrote:
>
> My naviserver nsdbipg module seems to barf on it.
> psql connects fine.

nsbipg is configured with a datasource param which lets you pass any
key=value pairs directly through to libpq.

According to:

  
http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS

...the default sslmode is prefer, which apparently means "don't bother
trying". You actually need sslmode=require.

nsdbpg unfortunately implements it's own datasource parsing so you're
stuck with user:host:db


Are you also using nsssl? Looks like some modifications are required:

  http://www.postgresql.org/docs/9.3/static/libpq-ssl.html#LIBPQ-SSL-INITIALIZE

  If your application initializes libssl and/or libcrypto libraries
and libpq is built
  with SSL support, you should call PQinitOpenSSL to tell libpq that the libssl
  and/or libcrypto libraries have been initialized by your application, so that
  libpq will not also initialize those libraries.

But you could try connecting to the db via ssl with nsssl unloaded, to
confirm that it works.

Not sure what the best way is to coordinate with nsssl who should init
the openssl library.

--
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-06 Thread Stephen Deasey
On Tue, Dec 4, 2012 at 10:55 PM, Gustaf Neumann  wrote:
> Am 04.12.12 20:06, schrieb Stephen Deasey:
>
> - we should actually ship some code which searches for *.gz versions of
> static files
>
> this would mean to keep a .gz version and a non-.gz version in the file
> system for the cases, where gzip is not an accepted encoding. Not sure, i
> would like to manage these files and to keep it in sync the fast-path
> cache could keep gzipped copies, invalidation is already there.

I guess it depends on how the website is deployed: in a more modern
set-up CSS is often compiled from SASS or LESS; javascript needs to be
minified and combined, possibly compiled using Google's optmising
compiler, maybe from coffee script; images are compressed, etc. Making
gzip versions of static text/* files is just one more target in a
Makefile.  Which is a little different than the old PHP/OpenACS
perspective where everything happens at run-time.

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-06 Thread Stephen Deasey
On Tue, Dec 4, 2012 at 10:24 PM, Gustaf Neumann  wrote:
>
> Today, i was hunting another problem in connection with nsssl, which
> turns out to be a weakness of our interfaces. The source for the problem
> is that the buffer management of OpenSSL is not aligned with the buffer
> management in naviserver. In the naviserver driver, all receive requests
> are triggered via the poll, when sockets are readable. With OpenSSL it
> might be as well possible that data as a leftover from an earlier
> receive when a smaller buffer is provided. Naviserver requested during
> upload spool reveive operations with a 4KB buffer. OpenSSL might receive
> "at once" 16KB. The read operation with the small buffer will not drain
> the OpenSSL buffer, and later, poll() will not be triggered by the fact,
> that the socket is readable (since the buffer is still quite full). The
> problem happened in NaviServer, when the input was spooled (e.g. file
> uploads). I have doubts that this combination ever worked. I have
> corrected the problem by increasing the buffer variable in the driver.c.
> The cleaner implementation would be to add an "Ns_DriverReadableProc
> Readable"  similar to the "Ns_DriverKeepProc Keep", but that would
> effect the interface of all drivers.

Another way to use the openssl library is to manage socket read/writes
yourself and hand memory buffers to openssl to encrypt/decrypt.

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-04 Thread Stephen Deasey
On Wed, Nov 28, 2012 at 10:38 AM, Gustaf Neumann  wrote:
>
> It is interesting to see, that with always 5 connections threads running and
> using jemalloc, we see a rss consumption only slightly larger than with
> plain tcl and zippy malloc having maxthreads == 2, having less requests
> queued.
>
> Similarly, with tcmalloc we see with minthreads to 5, maxthreads 10
>
>requests 2062 spools 49 queued 3 connthreads 6 rss 376
>requests 7743 spools 429 queued 359 connthreads 11 rss 466
>requests 8389 spools 451 queued 366 connthreads 12 rss 466
>
> which is even better.

Min/max threads 5/10 better than 2/10? How about 7/10? When you hit
10/10 you can delete an awful lot of code :-)

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-04 Thread Stephen Deasey
On Tue, Dec 4, 2012 at 10:55 PM, Gustaf Neumann  wrote:
>
> The code in naviserver-connthreadqueue handles already read-aheads with SSL.
> i have removed there these hacks already; i think, these were in part
> responsible for the sometimes erratic response times with SSL.

Well, I think the thing here is one-upon-a-time SSL was considered
computationally expensive (I don't know if it still is, with recent
Intel cpus having dedicated AES instructions etc.). Read-ahead is good
because you don't want an expensive conn thread waiting around for the
whole request to arrive, packet by packet. But with SSL the single
driver thread will be decrypting read-ahead data for multiple sockets
and may run out of cpu, stalling the request pipeline, starving the
conn threads. By making the SSL driver thread non-async you lose out
on read-ahead as that all happens on the conn thread, but you gain cpu
resources on a multi-cpu system (all of them, today). AOLserver 4.5
added a pool of read-ahead threads, one per-socket IIRC, to keep the
benefits of read-ahead while gaining cpu parallelism.

- does a single driver thread have enough computational resources to
decrypt all sockets currently in read-ahead? This is going to depend
on the algorithm. Might want to favour AES if you know your cpu has
support.
- which is worse, losing read-ahead, or losing cpu-parallelism?
- if a read-ahead thread-pool is added, should it be one thread
per-socket, which is simple, or one thread per-cpu and some kind of
balancing mechanism?

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-04 Thread Stephen Deasey
On Thu, Nov 29, 2012 at 6:51 PM, Gustaf Neumann  wrote:
>
> It turned out
> that the large queueing time came from requests from taipeh, which contained
> several 404 errors. The size of the 404 request is 727 bytes, and therefore
> under the writersize, which was configured as 1000. The delivery of an error
> message takes to this site more than a second. Funny enough, the delivery of
> the error message blocked the connection thread longer than the delivery of
> the image when it is above the writersize.
>
> I will reduce the writersize further, but still a slow delivery can even
> slow down the delivery of the headers, which happens still in the connection
> thread.

This shouldn't be the case for strings, or data sent from the fast
path cache, such as a small file (a custom 404), as eventually those
should work their way down to Ns_ConnWriteData which will construct
the headers if not already sent and pass them, along with the data
payload to writev(2). Linux should coalesce the buffers and send in a
single packet, if small enough.

I wonder if this is some kind of weird nsssl interaction.

(For things like sendfile without ssl we could use TCP_CORK to
coalesce the headers with the body)

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-04 Thread Stephen Deasey
On Mon, Dec 3, 2012 at 10:38 AM, Gustaf Neumann  wrote:
>
> All changes are on bitbucket (nsssl and naviserver-connthreadqueue).


I found this nifty site the other day:

https://www.ssllabs.com/ssltest/analyze.html?d=next-scripting.org

It's highlighting a few things that need fixed in the nsssl module,
including a couple of security bugs. Looks like relatively little code
though.

Also, there's this:

https://insouciant.org/tech/ssl-performance-case-study/

which is a pretty good explanation of things from a performance point
of view. I haven't spent much time looking at SSL. Looks like there
could be some big wins. For example, some of the stuff to do with
certificate chains could probably be automated - the server could spit
out an informative error to the log if things look poorly optimised.

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-12-04 Thread Stephen Deasey
On Tue, Dec 4, 2012 at 5:21 PM, Gustaf Neumann  wrote:

>
> * Only content sent via Ns_ConnWriteVChars has the chance to get
> compressed.
>

ie. dynamic content with a text/* mime-type. The idea here was you don't
want to try and compress gifs an so on, and static content could be
pre-compressed on disk - at runtime simple look for a *.gz version of the
content.

This could be cleaned up a bit by:

- having an extendable white-list of mime-types which should be compressed:
text/*, application/javascript, application/xml etc.

- we should actually ship some code which searches for *.gz versions of
static files



> * Similarly, range requests are not handled when the data is not sent
> ReturnOpen to the writer Queue.
>

The diagram shows Ns_ConnReturnData also calls ReturnRange, and hence the
other leg of fastpath and all the main data sending routines should handle
range requests.



>
> * there is quite some potential to simplify / orthogonalize the servers
> infrastructure.
> * improving this structure has nothing to do with
> naviserver-connthreadqueue, and should happen at some time in the main tip.
>


The writer thread was one of the last bits of code to land before things
quietened down, and a lot of the stuff that got talked about didn't get
implemented. One thing that was mentioned was having a call-back interface
where you submit a function to the writer thread and it runs it. This would
allow other kinds of requests to be served async.

One of the things we've been talking about with the connthread work is
simplification. The current code, with it's workarounds for stalls and
managing thread counts is very complicated. If it were simplified and
genericised it could also be used for background writer threads, and SSL
read-ahead threads (as in aolserver > 4.5). So, that's another +1 for
keeping the conn threads simple.
--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-11-18 Thread Stephen Deasey
On Sun, Nov 18, 2012 at 1:22 PM, Gustaf Neumann  wrote:
> On 14.11.12 09:51, Gustaf Neumann wrote:
>
> On 13.11.12 15:02, Stephen Deasey wrote:
>
> On Tue, Nov 13, 2012 at 11:18 AM, Gustaf Neumann  wrote:
>
> minthreads = 2
>
> creating threads, when idle == 0
> 10468 requests, connthreads 267
> total cputime 00:10:32
>
> creating threads, when queue >= 5
> requests 10104 connthreads 27
> total cputime 00:06:14
>
> What if you set minthreads == maxthreads?
>
> The number of thread create operations will go further down.
>
> Here are some actual figures with a comparable number of requests:
>
> with minthreads==maxthreads==2
>requests 10182 queued 2695 connthreads 11 cpu 00:05:27 rss 415
>
> below are the previous values, competed by the number of queuing operations
> and the rss size in MV
>
> with minthreads=2, create when queue >= 2
>requests 10104 queued 1584 connthreads 27 cpu 00:06:14 rss 466
>
> as anticipated, thread creations and cpu consumption went down, but the
> number of queued requests (requests that could not be executed immediately)
> increased significantly.

I was thinking of the opposite: make min/max threads equal by
increasing min threads. Requests would never stall in the queue,
unlike the experiment you ran with max threads reduced to min threads.
But there's another benefit: unlike the dynamic scenario requests
would also never stall in the queue when a new thread had to be
started when min < max threads.

What is the down side to increasing min threads up to max threads?

> Maybe the most significant benefit of a low maxthreads value is the reduced
> memory consumption. On this machine we are using plain Tcl with its "zippy
> malloc", which does not release memory (once allocated to its pool) back to
> the OS. So, the measured memsize depends on the max number of threads with
> tcl interps, especially with large blueprints (as in the case of OpenACS).

Right: the max number of threads *ever*, not just currently. So by
killing threads you don't reduce memory usage, but you do increase
latency for some requests which have to wait for a thread+interp to be
created.

Is it convenient to measure latency distribution (not just average)? I
guess not: we record conn.startTime when a connection is taken out of
the queue and passed to a conn thread, but we don't record the time
when a socket was accepted.


Actually, managing request latency is another area we don't handle so
well. You can influence it by adjusting the OS listen socket accept
queue length, you can adjust the length of the naviserver queue, and
with the proposed change here you can change how aggressive new
threads are created to process requests in the queue. But queue-depth
is a roundabout way of specifying milliseconds of latency. And not
just round-about but inherently imprecise as different URLs are going
to require different amounts of time to complete, and which URLs are
requested is a function of current traffic. If instead of queue size
you could specify a target latency then we could maybe do smarter
things with the queue, such as pull requests off the back of the queue
which have been waiting longer than the target latency, making room
for fresh requests on the front of the queue.

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver with connection thread queue

2012-11-13 Thread Stephen Deasey
On Tue, Nov 13, 2012 at 11:18 AM, Gustaf Neumann  wrote:
>
> minthreads = 2
>
> creating threads, when idle == 0
>10468 requests, connthreads 267
>total cputime 00:10:32
>
> creating threads, when queue >= 5
>requests 10104 connthreads 27
>total cputime 00:06:14

What if you set minthreads == maxthreads?

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_return* documentation and ns_register_* "default" method

2012-11-02 Thread Stephen Deasey
On Thu, Nov 1, 2012 at 12:13 PM, Gustaf Neumann  wrote:
>
> i think, that adding a command reference would be a nice
> addition, and is most likely possible with reasonable amount
> of work. The other alternative would be to split up the
> documentation pages with multiple commands into single pages...

The idea was to head in the other direction: consolidate similar
commands into one page.

For example for the ns_return page there's a couple of paragraphs of
explanation at the top that applies to all the commands, and by
collecting them together it's easy to see how they're similar and how
they differ. (maybe the 3 redirect commands should be split into their
own page?)

On the other hand, some times you just want a big list of all
commands...  Hopefully dtplite can be coaxed into generating it.

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_return* documentation and ns_register_* "default" method

2012-11-02 Thread Stephen Deasey
On Wed, Oct 31, 2012 at 12:54 PM, Stefan Sobernig
 wrote:
>
> I'd also appreciate a heads-up on a previous thread:
>
> http://www.mail-archive.com/naviserver-devel@lists.sourceforge.net/msg01811.html
>
> Was the idea of a "default" method ("*" or the like) for the
> ns_register_* cmd family ever implemented?

No.

Looks like some surgery to nsd/urlspace.c might be required to alter
the current order of lookup from: method, path, path for the url GET
/foo/bar to: path, path, method, so that if the path matches and the
method does not, a default method handler can be returned.

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Changing pageroot

2012-11-02 Thread Stephen Deasey
On Thu, Nov 1, 2012 at 4:03 PM, David Osborne  wrote:
>
> Trying to work out if this is a config error or a code difference... any
> pointers?

In general, add this to your config:

ns_section "ns/parameters"
ns_param   logdev  true

And the log file will tell you exactly which config parameters are
being accessed, with which values and types, what the defaults are,
etc.  It's worthwhile doing this just because config files tend to
accumulate cruft after a while.

--
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_urldecode -charset

2012-10-30 Thread Stephen Deasey
On Tue, Oct 30, 2012 at 7:59 PM, Stephen Deasey  wrote:
>
> But the code points of iso88591 are a subset of utf8...

Actually, this doesn't make sense. The byte encoding of code points
above 128 uses two bytes for utf8, but only one byte for iso88591.

Looks like you need -charset.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_urldecode -charset

2012-10-30 Thread Stephen Deasey
On Tue, Oct 30, 2012 at 10:38 AM, David Osborne  wrote:
> Hi,
>
> We're currently in the process of porting a fairly large code base from
> Aolserver to Naviserver for testing (using Naviserver v4.99.4 on Debian
> Squeeze).
>
> One thing that has come up so far is that ns_urldecode seems to have dropped
> the "-charset" switch.
>
> I'm assuming it used to be present since some of your documentation mentions
> it:
> (eg. http://naviserver.sourceforge.net/n/naviserver/files/ns_urldecode.html
> )
> I can't find any mention of why it was dropped?


It was more than 7 years ago so I can't remember the details, but I
think there were some other bugs to do with character sets that
basically meant forcing everything to be utf-8. Strictly speaking the
-charset switch to ns_urldecode might still be needed, and I think it
got removed by mistake, but it's usually not needed:

> So in Naviserver, is there an alternative to achieve the following:
>
> nscp 1> ns_urldecode -charset iso8859-1 "%FA"
> รบ

Here for example, if you don't pass -charset then naviserver assumes
utf8. But the code points of iso88591 are a subset of utf8 (and ascii
is a subset of both), so the result is identical. So you should never
have to specify iso88591, because I think you can no longer set the
notion of a global default character set -- it's always utf8, and then
in some places you can specifically choose if really needed.

Where are you getting %FA from? Is it something you're encoding
yourself or are you interacting with another system?


> PS. This is not really a devel question - is there a more appropriate place
> to ask config/user questions?


This is it.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] compression

2012-10-27 Thread Stephen Deasey
On Sat, Oct 27, 2012 at 1:13 PM, Gustaf Neumann  wrote:
> On 26.10.12 15:47, Stephen Deasey wrote:
>> I think the spec says that for HTTP/1.1, if the client doesn't
>> explicitly say to NOT send the body gzipped, say by using a q value of
>> 0 (which we don't actually check for, woops...), then the server can
>> choose the encoding, although it should prefer the identity, unless
>> that's unavailable. So we're being very pushy...
>
> now we do check for the qvalues used in connection with
> gzip. So, a client can now specify explicitly, that gzip is
> NOT wanted via "gzip; q=0". What the code still does not do
> is comparing the identity-qvalue with the gzip-qvalue or
> combination with wildcards "*;q=..."

Jeff had a go at this as well:

  https://bitbucket.org/jeffr/naviserver-queues/changesets

Here's the feedback I tacked on to the end of a mercurial question via email:



It bothers me a bit that a fresh Ns_Set has to be allocated, and also
the parsing code is pretty gnarly and hard to verify. It looks about
right, but I'd have to resort to pencil and paper to be more sure, and
the fact I haven't done that reminds me that people tend to not look
too closely at these things and that's where bugs can fester. I wonder
if there's another way of doing this...

You'll have to double check the details, but IIRC q values go from
0-999. If 'gzip' is present without a q value then it's as if it had
q=1 -- that's the default. If it's not present, it's as if it were but
with q=0. So, how about a function like Ns_HeaderQ(header, attr) which
returns the integer q value for the specified atttribute. It simply
uses strstr to find gzip. If it doesn't, return 0. If it does, then
check for a q=. If it's the character '0', return 0. If there's no q,
return 1. If it's something else, parse the int and return that. Then
you can use it something like:


if (!(connPtr->flags & NS_CONN_SENTHDRS)
   && !(connPtr->flags & NS_CONN_SKIPBODY)) {

contentEncoding = Ns_SetIGet(Ns_ConnHeaders(conn), "Accept-Encoding");

if (Ns_HeaderQ(contentEncoding, "gzip") > 0 ||
Ns_HeaderQ(contentEncoding, "*") > 0) {
gzip = 1;


I'm not sure how eager the server should be sending gzipped content.
An alternative to the above would be to keep the existing eager use of
gzip, but respect the client's negative assertion:


if (!(connPtr->flags & NS_CONN_SENTHDRS)
   && !(connPtr->flags & NS_CONN_SKIPBODY)) {

contentEncoding = Ns_SetIGet(Ns_ConnHeaders(conn), "Accept-Encoding");

if (connPtr->request->version >= 1.1) {
if ((!Ns_HeaderQ(contentEncoding, "gzip", &q) || q > 0)
&& (!Ns_HeaderQ(contentEncoding, "*", &q) || q > 0)) {
gzip = 1;
}
} else if ((Ns_HeaderQ(contentEncoding, "gzip", &q) && q > 0)
   || (Ns_HeaderQ(contentEncoding, "*", &q) && q > 0)) {
gzip = 1;
}


Here Ns_HeaderQ is modified to return NS_TRUE or NS_FALSE depending on
whether the attribute is present, and the q value is returned into the
given variable. HTTP 1.0 clients have to explicitly ask for gzip, 1.1
clients get it unless the say they don't want it.

--
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] lurking bugs: conn threads

2012-10-27 Thread Stephen Deasey
On Fri, Oct 26, 2012 at 11:41 PM, Jeff Rogers  wrote:
> Stephen Deasey wrote:
>> .., but I wonder if
>> we're even attempting to do the right thing?
>
> Do we even know what the right thing is?  It could be any of
> - ...
> - minimize resource usage
> - adapt to dynamically changing workload
> - ...

Right, but you can't actually use the memory that temporarily running
fewer threads frees up because the threads may be restarted at any
moment, so the goal of adapting and minimizing is not being met.
Memory is being wasted, not recycled. (maybe, that's what I'm
suggesting...)

> Not only that, but memory isn't always released back to the system when
> free()d.  (vtamlloc is supposed to be able to, but I haven't had too
> much success with it so far.)  So freeing memory by shutting down
> threads won't necessarily make that available to your database.

I think glibc these days uses POSIX_MADV_DONTNEED on ranges within
mmap'd areas it uses for malloc. It doesn't reduce the address usage,
so this only shows up as lower RSS under top.


> Server resources (memory) is either 'small' for requests that do not
> need a tcl interp (although tcl filters could tend to make this a
> nonexistent set), or 'big' for those that do.  Time is either slow or
> fast, by some arbitrary measure.
>
> So a small/fast pool could be set up to serve static resources, a
> big/fast pool for non-database scripts, and a big/slow pool for database
> stuff.

Naviserver has some stuff which AOLserver doesn't to help with this
partitioning. Gustaf gave an example the other day where a server gets
a small burst of traffic, a couple of page requests, but the browser
simultaneously requests all the css and javascript etc., which causes
a bunch of new threads to be created and a stall as they all have
their interps allocated.

You can create a non-tcl pool as well as the default pool and then use
some tricks to force certain types of requests not to use Tcl.

- ACS registers a default handler for /*, but naviserver exposes
ns_register_fastpath with which you can re-register the pure C
fastpath handler for /*.css etc.

- ACS has an elaborate search path for files so the above is not
enough. But naviserver provides the url2file callback interface. A
pure C version of the algorithm which maps a url path to a file path
code be coded and then the fastpath code would correctly find package
specific static assets.

- There's auth filters and so on registered for /* but again they
aren't needed for /*.css. You can use ns_shortcut_filter to push a
null filter to the front of the filter queue which simply returns OK
and prevents the rest from running.


> The small/fast pool would only need a small number of threads with a
> high maxconnsperthread, while the large/slow pool might have many
> threads as most of those will be blocking on database access at any
> given time.

This is sort of a recreation of the memory situation I was suggesting
may bot be working. Balancing memory between naviserver and postgress
is like balancing the threads (memory) in two pools. The max number of
threads across all pools can't be so high that it overwhelms the
server. Within that constraint you have to balance the threads between
the pools. If you have two pools each with 10 threads, and one pool is
busy but the other is idle, then the server is not running to
capacity, but you may have to reject requests. If you increase the
threads in the busy pool, the other pool may also become busy and now
the server is overwhelmed.

Tcl-using conn threads are often so memory intensive it seems like it
would always be a win to have two conn thread pools for Tcl and
non-Tcl threads. To partition further there's ns_limits but that's not
hooked up and needs more work.

--
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] lurking bugs: conn threads

2012-10-27 Thread Stephen Deasey
On Fri, Oct 26, 2012 at 11:44 PM, Jeff Rogers  wrote:
> Andrew Piskorski wrote:
>> On Fri, Oct 26, 2012 at 08:30:26PM +0100, Stephen Deasey wrote:
>>
>>> I was thinking it could work something like this:
>>>
>>> - driver acquires lock, takes first conn thread off queue, releases lock
>>
>> What if there are no conn threads waiting in the queue?
>>
>
> Same as currently I'd think: the driver holds on to them as waiting
> sockets.  I think the handling of this is a bit less efficient than
> putting them on the conn queue tho, as it creates more work for the
> driver to do on every spin and it needs to get woken up once threads are
> available.

- driver takes the lock, sees that there are no threads in the thread
queue, puts conn on the back of the conn queue, does not signal
anything, releases the lock

- conn thread completes a request, takes the driver lock.
-- If the conn queue is empty it puts itself on the front of the
thread queue and releases the lock.
-- Otherwise it takes then next conn and releases the lock.

--
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] lurking bugs: conn threads

2012-10-26 Thread Stephen Deasey
Interesting, but I wonder if we're not thinking this through
correctly. My suggestion, and your here, and Gustaf's recet work are
all aimed at refining the model as it currently is, but I wonder if
we're even attempting to do the right thing?

> So I'm assuming that the available processing power - the number of
> threads - should correlate to how busy the server is.  A server that is
> 50% busy should have 50% of its full capacity working.

But what is busy, CPU?  There needs to be an appropriate max number of
threads to handle the max expected load, considering the capabilities
of the machine. Too many and the machine will run slower. But why kill
them when we're no longer busy?

- naviserver conn threads use a relatively large amount of memory
because there tends to be one or more tcl interps associated with each
one

- killing threads kills interps which frees memory

But this is only useful if you can use the memory more profitably some
where else, and I'm not sure you can.

It is incoming load which drives conn thread creation, and therefore
memory usage, not availability of memory. So if you kill of some conn
threads when they're not needed, freeing up some memory for some other
system, how do you get the memory back when you create conn threads
again? There needs to be some higher mechanism which has a global view
of, say your database and web server requirements, and can balance the
memory needs between them.

I think it might be better to drop min/max conn threads and just have
n conn threads, always:

- simpler code

- predictable memory footprint

- bursty loads aren't delayed waiting for conn threads/interps to be created

- interps can be fully pre-warmed without delaying requests

- could back-port aolserver's ns_pools command to dynamically set the
nconnthreads setting

With ns_pools you could do something like use a scheduled proc to set
the nconnthreads down to 10 from 20 between 3-5am when your database
is taking a hefty dump.


Thread pools are used throughout the server: multiple pools of conn
threads, driver spool threads, scheduled proc threads, job threads,
etc. so one clean way to tackle this might be to create a new
nsd/pools.c which implements a very simple generic thread pool which
has n threads, fifo ordering for requests, a tcl interface for
dynamically setting the number of threads, and thread recycling after
n requests. Then try to implement conn threads in terms of it.


btw. an idea for pre-warming conn thread interps: generate a synthetic
request to /_ns/pool/foo/warmup (or whatever) when the thread is
created, before it is added to the queue. This would cause the tcl
source code to be byte compiled, and this could be controlled
precisely be registering a proc for that path.

--
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] lurking bugs: conn threads

2012-10-26 Thread Stephen Deasey
On Thu, Oct 25, 2012 at 10:31 AM, Gustaf Neumann  wrote:
> I don't think, that a major problem comes from the "racy"
> notification of queuing  events to the connection threads.
> This has advantages (make os responsible, which does this
> very efficiently, less mutex requirements) and disadvantages
> (little control).


I think the current code works something like this:

- driver thread acquires lock, puts connection on queue, broadcasts to
conn threads, releases lock

- every conn thread waiting on the condition is woken up in some
arbitrary but approximately round-robin order, and maybe some of the
conn threads which aren't currently waiting pick up that message when
they do wait, because for performance these things aren't strictly
guaranteed (I may be remembering this wrong)

- n conn threads race to acquire the lock

- the one which gets the lock first take the conn from the queue and
release the lock

- it runs the connection, acquires the lock again, puts the conn back
on the queue, and release the lock

- meanwhile the other woken conn threads acquire then release the lock
with possibly nothing to do.


So for each request there can be up to 6 lock/unlock sequences by the
driver and active conn thread, plus a lock/unlock by n other conn
threads, all on one contended lock, plus the context switching
overhead, and this all happens in an undesirable order.


> By having a conn-thread-queue, the
> threads have to update this queue with their status
> information (being created, warming up, free, busy,
> will-die) which requires some overhead and more mutex locks
> on the driver.


I was thinking it could work something like this:


- driver acquires lock, takes first conn thread off queue, releases lock

- driver thread puts new socket in conn structure and the signals on
cond to that one thread (no locking, I don't think)

- that conn thread wakes up, takes no locks, runs connection

- conn thread acquires driver lock, puts conn back on front of queue,
releases lock


Four lock/unlock, lock/unlock sequences, two threads.

--
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Hello

2012-10-26 Thread Stephen Deasey
On Wed, Oct 24, 2012 at 5:01 PM, Agustin Lopez  wrote:
>
> When I run the server I get error with Ns_ConfigSection from my compiled
> nsldap.
> I suppose that it is a known problem. Any pointer to work it?

What is the exact error message?

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] compression

2012-10-26 Thread Stephen Deasey
On Thu, Oct 25, 2012 at 9:20 PM, Jeff Rogers  wrote:
> It looks like we're enabling compression for all http/1.1 requests
> regardless of whether it was specified in the request header, or even
> specifically disallowed.  This seems incorrect, but the code has been in
> place for several years (connio.c:CheckCompress) ;  is there a reason
> not to change that?

I think the spec says that for HTTP/1.1, if the client doesn't
explicitly say to NOT send the body gzipped, say by using a q value of
0 (which we don't actually check for, woops...), then the server can
choose the encoding, although it should prefer the identity, unless
that's unavailable. So we're being very pushy...

There's a bunch of tests for this in tests/ns_adp_compress.test,
including with and without the Accept-Encoding header and q values,
but many of them are disabled with -constraints knownBug. I guess it's
something someone thought about but no one got round to fixing it.

This page describes how to run these particular tests:

  http://wiki.tcl.tk/21659

> Also on compression, a separate compression stream is pre-allocated and
> initialized for each pre-allocated Conn, whether or not compression is
> even enabled for the server.  The causes a fairly large initial memory
> footprint.  I think this pre-initialization could be made optional, and
> bypassed entirely when compression isn't enabled.  Any thoughts?

Seems reasonable.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] [AOLSERVER] Naviserver Win-64 Sources

2012-10-17 Thread Stephen Deasey
On Wed, Oct 17, 2012 at 4:55 AM, Maurizio Martignano
 wrote:
> OK
>
> Simple reason: Visual Studio complains about that stuff and it is annoying.

Looks like Visual Studio 2012 comes with a C compiler:

  http://msdn.microsoft.com/en-us/library/bb384838.aspx

"Visual Studio includes a C compiler that you can use to create
everything from basic C programs to Windows API applications."

"By default, the Visual C++ compiler treats all files that end in .c
as C source code,"

Maybe there's a bug in your build scripts that are forcing C code to
be treated as C++?

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] lurking bugs: conn threads

2012-10-11 Thread Stephen Deasey
On Wed, Oct 10, 2012 at 9:44 PM, Jeff Rogers  wrote:
>
> It is possible to get into a situation where there are connections
> queued but no conn threads running to handle them, meaning nothing
> happens until a new connection comes in.  When this happens the server
> will also not shut down cleanly.  As far as I can figure, this can only
> happen if the connection queue is larger than connsperthread and the
> load is very bursty (i.e., a load test);  all the existing conn threads
> can hit their cpt and exit, but a new conn thread only starts when a new
> connection is queued.  I think the solution here is to limit
> maxconnections to no more than connsperthread.  Doing so exposes a less
> severe problem where connections waiting in the driver thread don't get
> queued for some time; it's less of a problem because there is a timeout
> and the dirver thread will typically wake up on a closing socket fairly
> soon, but it can still result in a simple request taking ~3s to
> complete.  I don't know how to fix this latter problem.

I think this is racy because all conn threads block on a single
condition variable. The driver thread and conn threads must cooperate
to manage the whole life cycle and the code to manage the state is
spread around.

If instead all conn thread were in a queue, each with it's own
condition variable, the driver thread could have sole responsibility
for choosing which conn thread to run by signalling it directly,
probably in LIFO order rather than the current semi-round-robin order
which tends to cause all conn threads to expire at once. Conn threads
would return to the front of the queue, unless wishing to expire in
which case they'd go on the back of the queue, and the driver would
signal when it was convenient to do so. Something like that...

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] lurking bugs: file name encoding

2012-10-11 Thread Stephen Deasey
On Wed, Oct 10, 2012 at 9:44 PM, Jeff Rogers  wrote:
>
> ns_returnfile doesn't decode passed filenames from tcl correctly.  As a
> result, [file exists $file] could report that a file does exist but
> [ns_returnfile 200 text/html $file] could give a "not found" error.  The
> circumstances needed to make this happen are uncommon (changing tcl's
> system encoding, actually having files in strange encodings) but it is
> possible.  Fix should be to pass the argument to ns_returnfile through
> Tcl_UtfToExternalDString to get a 'native' file name.

There's been a bunch of stuff done to handle reading and writing bytes
to the connection in the right encoding. As part of that, naviserver
forces the system encoding to utf8 on start-up (this is usually keyed
off env variables). That makes Tcl_UtfToExternalDString a no-op. I
think it's the case that some code assumes Tcl's system encoding is
always utf8, and if it's not things will break. I may be
miss-remembering some of this.

You'll want a precise test case to nail down the circumstances of the
bug. There's some related tests in tests/encoding.test and
tests/tclresp.test.

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_set ... -persistent

2012-10-10 Thread Stephen Deasey
On Wed, Oct 10, 2012 at 10:09 AM, Gustaf Neumann  wrote:
>
> Using a "_ns_set" capable of handling "-shared" which just calls
> existing "ns_set" with the unlocked semantics would not work,
> using a lock with for all "_ns_set" commands is not good either
> without modifying the existing "ns_set" semantics (one should
> not be able to access variables created by "_ns_set" from
> "ns_set"). If we check for the shared flag in "ns_set", we are
> essentially at the old "ns_set" implementation.

I was thinking that the 2 or 3 people in the world that need backward
compatibility would load the nsshare module and then:

  rename _ns_set ns_set

You wouldn't use them both, you just want your old code to work the
way it did in 1999.

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Greetings

2012-10-09 Thread Stephen Deasey
On Tue, Oct 9, 2012 at 7:49 PM, Zoran Vasiljevic  wrote:
>
> On 09.10.2012, at 20:10, Jeff Rogers wrote:
>
> Hi Jeff!
>
>> Propose
>> changes on the development list and then make changes to the main
>
> This is how we have worked so far. This mostly covers bug fixes.
> Whole-sale changes are little bit different... but they happen
> seldom. In that case, a branch consisting of all the changes is
> prefered.

Conceptually yes, but don't actually use a mercurial branch for
temporary development. You can't delete branches.

On your local computer just clone an existing checkout into a new
directory, it'll use hard links so it's fast and efficient. If you
want to publish it for feedback then click the 'fork' button on the
naviserver project at bitbucket and create a new repo under your own
account: push your changes directly to it. If it's a small change,
just post it here.


Anyway, if you think of vc as backup and approval then it sounds like
a drag, but it's really more like your editor - it helps you code.

You often don't know what you're going to end up with when you start
so you use your editor and hg to manipulate the code.
- You start to add a feature but half way through you realise if you
refactored some existing functions it would make the addition easier.
- So, pop-off what you've done so far, refactor the code, push your
pending changes back.
- Then you notice a bug in some existing code. Pop off both changes,
fix the bug, push them back on again.
Now when you share the code there's 3 separate changes and they tell a
story: here's a simple bug fix, here's a refactoring which should not
change existing behaviour, and here's a new feature.

The easier it is to read the more people are likely to read it and the
more feedback you'll get, which is invaluable. In addition, everyone
who touches the code end up with a mental model of how it works, so
when the code changes the model needs to be synced up again. It's not
scalable to have each person slog through a big old dump of code that
took the original changer 6 hours to grok. You need to present it like
a story so it makes sense.

Check out the lkml to see how the ninjas do it.

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_set ... -persistent

2012-10-09 Thread Stephen Deasey
On Tue, Oct 9, 2012 at 7:49 PM, Jeff Rogers  wrote:
> I don't know that people love it so much as that there is no exact
> replacement for the functionality.
>
> I'm a big proponent of compatibility but shared sets as they previously
> existed are problematic.  I wouldn't be at all surprised if they are
> thread-unsafe to the point of being able to crash the server.
>
> An alternative might be to provide equivalent functionality
> (order-preserving, multiple entries for keys, access by index or key or
> case-insensitive key) as a new nsv subcommand, perhaps 'nsv_multiset'.

Hmm, sounds a bit like reintroducing the old code under a new name. I
think people are just unwilling to change old code, not specifically
looking for case-folding multi-sets.

> Separately, I was experimenting with a performance enhancement to
> ns_sets, creating a hashtable mapping the keys to indexes.  There is a
> slight cost in memory and on the first lookup, but it should get to
> breakeven after only around 3 lookups on average, with decreasing
> amortized cost after that.  The difference is measurable and can be
> significant, as much as 4x faster on a large set.  However, that's
> measured on a very large set, 1000 keys;  and the real savings is pretty
> small, around 15 microseconds per lookup on average hardware.  Is that
> kind of micro-optimization worth the additional complexity?

Sets are used in a few core places where this sounds like a disadvantage:

- http headers (in/out)
- html forms
- database rows

All low numbers of rows with few lookups. Even config values rarely
have huge numbers of elements, or duplicates, and often are looked up
only once at startup and then stashed away in a struct.

How are you planing to use these key/value structures?

If you're going to use them from a Tcl API within one interp then you
can use the Tcl object shimmering technique. If you make the lookup
key fully describe the value instead of using a two-part array-key
then after the first lookup you can store a pointer to the value in
the spare Tcl_Obj ptr. You can see this technique used in the arg
parsing machinery.

If you're sharing between interps you can't use that technique, but
there may be other things you can speed up. For example, here's a
project I never finished to create an API identical to Tcl hash tables
except that you can pre-allocate space for the value in the key
struct:

  https://bitbucket.org/groks/naviserver-nshash

The idea was to reduce memory fragmentation and be more cache
friendly, which gets more important as modern computers with numa
memory layouts and a large difference between cpu-memory speeds.

There's also this r/w config replacement:

  https://bitbucket.org/naviserver/nsconfigrw

which has links to some discussion about implementation, including
support for multiple values, case folding etc.

Or maybe you're trying to recreate PHP's do-everything hash-list
container... :-)

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] ns_set ... -persistent

2012-10-09 Thread Stephen Deasey
On Tue, Oct 9, 2012 at 11:11 AM, Gustaf Neumann  wrote:
> Stephen,
>
> do you remember why you took out the -shared flag from ns_set?
>
> https://bitbucket.org/naviserver/naviserver/changeset/1cbaf1acc09436f2a1c56102269a8b7fab0be168
>
>
> it seems that some people love it. We have either to take it
> out of
> the documentation (and give sensible explanation) or
> reintroduce it in the code...


If I remember rightly, the code has long been depreciated in
AOLserver, and as no one used it and it complicates the arg parsing
and locking we removed it, along with the ns_share and ns_var command.
There's Tcl wrapper for ns_var because it was trivial.

I've created a new module nsshare which reimplements the ns_share
command using the old C code:

  https://bitbucket.org/naviserver/nsshare/overview

Haven't put much effort into testing it, but the skeleton of the
module is ready to go, it compiles and the sanity tests work.

I think the way to add back the -shared switch to ns_set would be to
add a new file to this module: setcmd.c, add the C code that was
removed, export an _ns_set ?-shared? ?args ...? command which, if the
-shared flag is present does it's thing, otherwise calls the
underlying ns_set command. If you want to do this, that would be
great.

As there is now somewhere to put it, the ns_var code could be moved here too.

There's some compatibility info here:

  http://wiki.tcl.tk/22567

--
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] nsproxy module: change comm to sockets instead of pipes?

2012-01-28 Thread Stephen Deasey
On Sat, Jan 28, 2012 at 8:19 PM, Ibrahim Tannir  wrote:
>
> However, the entire asynchronous IO in Windows is really messy
> business, since the entire mechanism of processing IO
> notifications is tied to a window.

I see what y'all mean. That's a lot of non-shared code.

I suppose you can always use a unix domain socket on the unixy side
while using a socket on the loopback interface for Windows and still
use the same poll() code on both.

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] nsproxy module: change comm to sockets instead of pipes?

2012-01-28 Thread Stephen Deasey
On Sat, Jan 28, 2012 at 1:26 PM, Zoran Vasiljevic  wrote:
>
> On Windows there are some limitations as how you can
> do non-blocking operations... In particular, there
> seems to be a problem with non-blocking reads/writes
> on unnamed pipes... They simply do not work on windows,
> at least as to our knowledge.

I don't know anything about Windows, but i t looks like PIPE_NOWAIT
switches to non-blocking mode but is a legacy of ye olde lan manager,
and instead you should use overlapped IO with the FILE_FLAG_OVERLAPPED
flag:

  
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365788%28v=vs.85%29.aspx

This is all with named pipes. But it says the followinf about anon pipes:

  Anonymous pipes are implemented using a named pipe with
  a unique name. Therefore, you can often pass a handle to an
  anonymous pipe to a function that requires a handle to a named pipe.

So maybe you can substitute a named pipe with the appropriate flags
for the anon pipe?

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Socket buffer sizes

2010-05-10 Thread Stephen Deasey
On Mon, May 10, 2010 at 7:22 PM, Andrew Piskorski  wrote:
> On Mon, May 10, 2010 at 11:39:26AM +0200, Vasiljevic Zoran wrote:
>
>> So far I could understand from reading tons of docs
>> found all over the internet, the socket buffer sizes are
>> crucial for optimizing the network peformance related to
>> fast, high-latency links.
>
> Sounds like what the hpn-ssh patches do for ssh:
>
> http://www.psc.edu/networking/projects/hpn-ssh/


Zoran:

Looks like it would be a mistake to use setsockopt() on Linux >=
2.6.17 (released June 2006) ie. RHEL 5+ (ignoring any patches Redhat
may have backported):

http://www.psc.edu/networking/projects/tcptune/#detailed
http://kbase.redhat.com/faq/docs/DOC-3079

--

___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Socket buffer sizes

2010-05-10 Thread Stephen Deasey
On Mon, May 10, 2010 at 12:39 PM, Vasiljevic Zoran  wrote:
>
> What I have in mind is to:
>
> a. make necessary changes to the driver code so that socket options
> are set before we actually call listen().
>
> The a. is really the most work as it will require either chaning
> existing (sub-optimal) and/or adding new (more optimal) C-APIs.


Can you just take this from the config file? Make the default 0 and if
0, don't config the bufsize.


> b. add ?-socketbuffersize size? option to all Tcl API commands that
> work with sockets.
>
> The b. is relatively harmless and should be straight-forward once
> the a. is done.


Should there be some way to 'ignore' this if the OS can handle it
automatically?  Maybe you just pass [ns_config socket bufsize] to the
option and if it's 0, ignore it...?

--

___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Socket buffer sizes

2010-05-10 Thread Stephen Deasey
On Mon, May 10, 2010 at 10:39 AM, Vasiljevic Zoran  wrote:
> Hi!
>
> I am in the process of evaluating the possibility to
> "correct" the current behaviour WRT manipulating
> socket buffer sizes...
>
> So far I could understand from reading tons of docs
> found all over the internet, the socket buffer sizes are
> crucial for optimizing the network peformance related to
> fast, high-latency links. We have customers that would
> benefit from this so I need to find the way to make this
> happen in the Naviserver.


We talked about this in summer 2008, I think. It will be in your mail
or mailing list archives somewhere...


> I did find out that different OS'es handle such cases
> differently. Most of them require admins to tune either
> system or per-app buffer sizes to achieve good BDP
> (Bandwidh-Delay Product). Some (newer Linux'es) do this
> automatically.


Newer is relative. I think by now this means any linux, bsd, solaris
less than a decade old...


> Currently we do already manipulate the socket buffer sizes
> in the main driver code (only).
> Unfortunately this manipulation happens (at least for the
> read-buffer-size) too late! As I understand, the socket
> buffers for reading must be setup BEFORE listen() call.
> Whereas we manipulate the sizes AFTER the connection is
> established.


Which code are you looking at? IIRC, you removed this code years ago:

http://bitbucket.org/naviserver/naviserver/changeset/a6e8a6348da0

--

___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Ns_ConnWriteData needs Ns_ConnFlushData ?

2010-05-05 Thread Stephen Deasey
On Wed, May 5, 2010 at 8:46 AM, Vasiljevic Zoran  wrote:
>
> On 04.05.2010, at 18:58, Stephen Deasey wrote:
>
>>
>> What is being buffered that you're trying to flush?
>
> The headers! It is just a kind-of 304-type of response or
> a response containing just the headers, no data.
>
> In the "previous life" I used SetRequiredHeaders
> and then FlushHeaders. Now I need to set each thing
> per line and then call Ns_ConnWrite with NULL buffer:
>
> was:
>
> ย  ย  ย  ย  ย Ns_ConnSetRequiredHeaders(conn, mime, size);
> ย  ย  ย  ย  ย result = Ns_ConnFlushHeaders(conn, 200);
>
> is:
>
> ย  ย  ย  ย  ย Ns_ConnSetTypeHeader(conn, mime);
> ย  ย  ย  ย  ย Ns_ConnSetLengthHeader(conn, size);
> ย  ย  ย  ย  ย Ns_ConnSetResponseStatus(conn, 200);
> ย  ย  ย  ย  ย if (Ns_ConnWriteData(conn, NULL, 0, 0) != NS_OK) {
> ย  ย  ย  ย  ย  ย  ย result = 0;
> ย  ย  ย  ย  ย } else {
> ย  ย  ย  ย  ย  ย  ย result = size;
> ย  ย  ย  ย  ย }
>
> So the 2 liner becomes 8 liner. It is not that I really
> care about that, but what I find obscure is the ConnWriteData.
> Something like this would be more "readable"
>
> ย  ย  ย  ย  ย Ns_ConnSetTypeHeader(conn, mime);
> ย  ย  ย  ย  ย Ns_ConnSetLengthHeader(conn, size);
> ย  ย  ย  ย  ย Ns_ConnSetResponseStatus(conn, 200);
> ย  ย  ย  ย  result = Ns_ConnFlush(conn);
>
> So the hypothetical Ns_ConnFlush would write all that it can
> and return the number of bytes written. Or something like that.
> Is there some other means of achieving the above that I am not
> aware of?


In general:

result = Ns_ConnReturnData(conn, status, data, data_length, mime_type);

For responses without a body:

result = Ns_ConnReturnStatus(conn, status);

For 304's in particular:

result = Ns_ConnReturnNotModified(conn);

...and related in nsd/returnresp.c.  If there's a useful HTTP response
that's missing, you should probably just add it.


This example is kid of buggy:

>  Ns_ConnSetTypeHeader(conn, mime);
>  Ns_ConnSetLengthHeader(conn, size);
>  Ns_ConnSetResponseStatus(conn, 200);
>  if (Ns_ConnWriteData(conn, NULL, 0, 0) != NS_OK) {
>  result = 0;
>  } else {
>  result = size;
>  }

You've converted the NS_OK/NS_ERROR response from Ns_ConnWriteData to
a byte count, but that doesn't really tell you anything useful. In the
NS_ERROR case, some bytes might actually have been written, but you've
bashed it to zero. Setting result to size (the length header) is
misleading because the number of bytes written includes the bytes of
the headers, which the length header does not include. The byte count
can also be inflated because of character encoding and
chunked-encoding framing. It might actually be decreased because
compression.

What you can't do is compare bytes written to your original buffer
size and determine whether your write was successful. Which is one of
the reasons why FlushHeaders is depreciated.

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Ns_ConnWriteData needs Ns_ConnFlushData ?

2010-05-04 Thread Stephen Deasey
On Tue, May 4, 2010 at 4:58 PM, Vasiljevic Zoran  wrote:
> Hi!
>
> Quite often I see:
>
> ย  ย Ns_ConnWriteData(conn, NULL, 0, 0);
>
> This is OK but not very readable. Can we add something like
>
> ย  ย Ns_ConnFlushData(conn, flags)
>
> convenience wrapper that would supply the NULL buffer and
> zero bytes to the Ns_ConnWriteData() ?
>
> This would add zero functionality but would make the
> programmers intention more clear.


Hmm... well it's not *too* often that you see it. Some of the places
where it's currently done is probably a mistake, and sometimes it's
because the api doesn't quite let you do what you need.

For example, return.c:ReturnRange() flushes the headers by calling
Ns_ConnWriteData with a null buffer before calling
Ns_ConnSendFileVec() because the latter is low level enough, for
flexibility, that it completely ignores headers, for alternate
protocols etc. But the vector sending code can actually handle memory
buffers as well as files, so ideally you'd want to dump the headers to
a string buffer then pass them on to SendVec. Or something...

What is being buffered that you're trying to flush?

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Ns_ConnFlushHeaders() deprecated: why?

2010-05-04 Thread Stephen Deasey
On Tue, May 4, 2010 at 4:50 PM, Vasiljevic Zoran  wrote:
> Hi all!
>
> Tcl_WideInt
> Ns_ConnFlushHeaders(Ns_Conn *conn, int status)
> {
> ย  ย  Conn *connPtr = (Conn *) conn;
>
> ย  ย  Ns_ConnSetResponseStatus(conn, status);
> ย  ย  Ns_ConnWriteData(conn, NULL, 0, 0);
>
> ย  ย  return connPtr->nContentSent;
> }
>
> This function is set as deprecated. It returns number of bytes sent.
> I cannot see that connPtr->nContentSent is exposed from outside
> so how am I to obtain the original Ns_ConnFlushHeaders functionality
> w/o accessing internal connection state?


Flushing headers is discouraged because it isn't needed for HTTP, it's
slow, and often extra headers need to be added depending on which
Write* calls you use.

I guess you could give access to nContentSent in a new public API.
What are you using it for? How are you writing the data?

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: gustafn: - Fix to prevent multiple DriverAccepts on the same socket. The original coded relied on the fact that later accepts

2010-04-12 Thread Stephen Deasey
On Mon, Apr 12, 2010 at 3:58 PM, Gustaf Neumann  wrote:
>
> Cool, good guess, but it did not help - but the proposed
> change should go into the repository.


Actually this doesn't make any sense and shows how long it's been
since I've touched any C.


> But, i got that sucker: In the following ioctl (and others
> maybe as well) the "long" is wrong, since linux expects
> there an int. ย That's why we see the problem with 64bit
> machines and on bsd!


Well spotted.


> Does anyone know, how to figure out, on which platforms
> the long is wanted? The majority seems to be "int".


Not sure. Just go with int? How many people are running on MKS or Amiga?

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: gustafn: - Fix to prevent multiple DriverAccepts on the same socket. The original coded relied on the fact that later accepts

2010-04-12 Thread Stephen Deasey
On Mon, Apr 12, 2010 at 2:33 PM, Gustaf Neumann  wrote:
>
> Without the patch naviserver hangs (blocks) on that machine already
> at the first or second request.


This should never happen as the listen socket is set to non-blocking mode, here:

  http://bitbucket.org/naviserver/naviserver/src/tip/nssock/nssock.c#cl-131

nssock.c:Accept() calls nsd/sock.c:Ns_SockAccept() which calls
accept(2), who's man page says:

If no pending connections are present on the queue, and the socket
is not marked
as non-blocking, accept() blocks the caller until a connection is
present.  If the socket
is marked non-blocking and no pending connections are present on
the queue, accept()
fails with the error EAGAIN or EWOULDBLOCK.

In which case, Ns_SockAccept looks wrong:

SOCKET
Ns_SockAccept(SOCKET lsock, struct sockaddr *saPtr, int *lenPtr)
{
SOCKET sock;

sock = accept(lsock, saPtr, (socklen_t *) lenPtr);

if (sock != INVALID_SOCKET) {
sock = SockSetup(sock);
}

return sock;
}


Shouldn't this be something more like:

if (sock > -1) {
sock = SockSetup(sock);
}

as INVALID_SOCKET is -1 but there is more than one possible error state?

(I haven't tried this...)

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] driver changes, please check

2010-04-12 Thread Stephen Deasey
On Sun, Apr 11, 2010 at 4:42 PM, Gustaf Neumann  wrote:
>
> The current solution works, but returns the chunked markup
> (which is fine for me, doing the chunked-decode in Tcl),
> but should done in (similar to the chunked encoding for forms).


This is not going to work reliably because of the following, right?

http://bitbucket.org/naviserver/naviserver/changeset/a1ccb0371eee/#chg-nsd/driver.c_newline2239

if (reqPtr->avail > reqPtr->expectedLength) {
/*
 * Chunk encoded data is always larger than the expected
 * length; we hope that we have sufficient data collected
 */
reqPtr->length = reqPtr->avail;
} else {



> Actually, there must be a better way for this than the following
> change: http://bitbucket.org/naviserver/naviserver/changeset/a1ccb0371eee/


How about implementing chunked uploading?  It is a requirement of the
HTTP 1.1 spec.

There is already full support for writing chunked, with tests, and
there is support for parsing mime parts in the form parsing code.

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] driver changes, please check

2010-04-12 Thread Stephen Deasey
On Sun, Apr 11, 2010 at 4:42 PM, Gustaf Neumann  wrote:
>
> PS: i had to do a "hg push -f ...". Not sure, if this is intentional.
> Do the commits to tip look right?


All that's happened here is that you've made changes to your checkout
without first updating it. In the meantime, Zoran has made changes and
pushed them.

If this were CVS it would refuse to let you commit. With mercurial
obviously you can commit as it's local, but it will not let you push
and will give you a warning. You ignored the warning by using -f  :-)

You are going to have to merge the two heads with 'hg merge' and then
push that changeset. See: hg help merge.

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: gustafn: - Fix to prevent multiple DriverAccepts on the same socket. The original coded relied on the fact that later accepts

2010-04-12 Thread Stephen Deasey
On Sun, Apr 11, 2010 at 4:16 PM,   wrote:
>
> changeset: 2575:3963e46562e8
> user: Gustaf Neumann 
> date: Sun Apr 11 17:16:27 2010 +0200
> summary: Fix to prevent multiple DriverAccepts on the same socket.
>  The original coded relied on the fact that later accepts lead to
>  an ERROR_STATE. Under RHEL 4 (Power, 64bit) the second accept 
> blocks.
>
>
> diff --git a/nsd/driver.c b/nsd/driver.c
> --- a/nsd/driver.c
> +++ b/nsd/driver.c
> @@ -1523,7 +1523,22 @@ SockAccept(Driver *drvPtr, Sock **sockPt
>   * Accept the new connection.
>   */
>
> - status = DriverAccept(sockPtr);
> + /*
> + * Hmmm: the original implementation was written in style that
> + * DriverAccept was called twice, one to return for e.g. a simple,
> + * new HTTP request NS_DRIVER_ACCEPT (staying in the SOCK_MORE
> + * status), and then calling ACCEPT again, but which causes on our
> + * RHEL 4 system (POWER6, 64bit) a hang: the second accept blocks,
> + * while it returns under (most?) other system a
> + * NS_DRIVER_ACCEPT_ERROR. It seems that the original code rely on
> + * this ERROR handling. It is not clear to me, why the second call
> + * to ACCEPT is necessary, when the socket is already available.
> + */
> + if (*sockPtrPtr) {
> + status = NS_DRIVER_ACCEPT_ERROR;
> + } else {
> + status = DriverAccept(sockPtr);
> + }
>
>  if (status == NS_DRIVER_ACCEPT_ERROR) {
>  status = SOCK_ERROR;




> It is not clear to me, why the second call to ACCEPT is necessary, when the 
> socket is already available.



http://bitbucket.org/naviserver/naviserver/src/tip/nsd/driver.c#cl-1175 :


DriverThread():

if (waitPtr == NULL) {
/*
 * If configured, try to accept more than one request,
under heavy load
 * this helps to process more requests
 */

accepted = 0;
while (accepted < drvPtr->acceptsize
   && drvPtr->queuesize < drvPtr->maxqueuesize
   && PollIn(&pdata, drvPtr->pidx)
   && (n = SockAccept(drvPtr, &sockPtr)) != SOCK_ERROR) {

switch (n) {
...

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Where is ChangeLog?

2010-03-06 Thread Stephen Deasey
On Sat, Mar 6, 2010 at 5:43 PM, Vasiljevic Zoran  wrote:
>
> On 06.03.2010, at 16:30, Vasiljevic Zoran wrote:
>
>> Or should I need to do some other "magic" after "hg ci" ???
>
> I see: "hg push".


Yeah, 'commit' is local, 'clone' and 'push' are like rsync up and down.

You can also do 'incoming' and 'outgoing' to see what's pending a
'push' or 'pull'.


I haven't read this yet, but I expect it's good:

  http://hginit.com/

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Mercurial does not substitute tags?

2010-03-06 Thread Stephen Deasey
On Sat, Mar 6, 2010 at 1:18 PM, Vasiljevic Zoran  wrote:
> Hi!
>
> It seems to me that we miss RCS Tag substitution.
> Is this so deliberately? If yes, what's the point
> in keeping NS_RCSID any longer?
>
> < NS_RCSID("@(#) $Header: /Volumes/DATEN0/develop/local/CVS/dev/
> naviserver/nsd/queue.c,v 1.2 2008/04/29 08:11:15 zv Exp $");
> ---
> ย > NS_RCSID("@(#) $Header$");


Mercurial doesn't mangle the source code by default. There is a
plugin, included but disabled by default, that can do this, but I
haven't tried it.

Not sure whether it's worth the bother to set that up, remove the
unused RCS tags, or just leave it be...

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Where is ChangeLog?

2010-03-06 Thread Stephen Deasey
On Sat, Mar 6, 2010 at 1:03 PM, Vasiljevic Zoran  wrote:
> Hi!
>
> After some (longer) absence (first things first) I am
> now trying to catch-up with the Mercurial repository.
>
> First thing that I noticed after checking out the
> repository was that ChangeLog file is missing.
> Any idea why? Do we not need it any more?


That's right, it's not needed anymore.

Because of the way that mercurial works, when you 'clone' (ie. cvs
checkout) you get the whole repository on your local hard drive, not
just the HEAD (which we now call 'tip').

So, when you do a 'hg log' you can see all changes ever made without
hitting the network.

Also, if you want something easier to browse, try doing 'hg serve' and
then connecting to localhost with your browser.

--
Download Intelยฎ Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] spooler not working on linux

2009-11-22 Thread Stephen Deasey
On Sun, Nov 22, 2009 at 3:26 AM, Vlad Seryakov  wrote:
> Once the server started, connect to nscp console and issue
>
> ns_logctl severity Debug(ns:driver) true
>
> now in the nsd.log there must be a lot of driver and spooler related
> messages


I think you should be able to do this at any time, not just in the
control port. So for example, you could just stick it in the config
file.

http://naviserver.sourceforge.net/n/naviserver/files/ns_log.html

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] spooler not working on linux

2009-11-22 Thread Stephen Deasey
On Sun, Nov 22, 2009 at 2:58 AM, John Buckman  wrote:
>
> Perhaps the problem is how I built my naviserver on linux? ย I simply ran 
> "autogen.sh" from the cvs tree, and I also tried it with
> ./autogen.sh --enable-threads --enable-symbols ย --with-tcl=/usr/local/lib


The latest source is here, not in CVS:

  http://bitbucket.org/naviserver/naviserver/


(If you've found an old link to CVS, let us know so we can change it)

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] large memory usage when uploading

2009-11-19 Thread Stephen Deasey
On Thu, Nov 19, 2009 at 2:25 AM, John Buckman  wrote:
> I'm writing an app that accepts large file uploads, and trying to lower the 
> memory requirements.
>
> When I upload large files, at the point where the files are completely 
> uploaded, Naviserver consumes an equivalent amount of memory as the file 
> uploaded size, as it hands control over to my form handler. Memory is 
> released once my form handler returns. ย Virtually no memory is used (thanks, 
> spooler) as the large file is being uploaded, only once the upload completes.
>
> I'm not sure why Naviserver needs to hold the file in memory.
>
> So, questions:
>
> a) is this by design?
> b) has anyone on this list worked on this section of code?
> c) any fixes, or should I plunge into the nsd/form.c code (is that right?) to 
> try to fix this?


We originally talked about this way back in 2005:

http://sourceforge.net/mailarchive/message.php?msg_id=37583D44-1F17-401D-8BCA-26F816831B92%40archiware.com

Spooling got implemented later.

What didn't didn't get implemented, and what you're tripping over, is
the on-the-fly parsing of file-upload mime headers so that *only* the
contents of the actual file becomes a file spooled on disk, and not
the file topped and tailed with mime headers.  As you've discovered,
the way the form parsing is implemented it just reads the whole thing
back into memory anyway, negating the benefit of spooling to disk.

Ideally, the spooler thread would parse the form as it is read in
chunks from the socket, placing variables in the form structure, and
spooling file contents to disk. If more than one file is in the form
then multiple spool files would be used.

Watch out for encoding. IIRC the way it currently works forms can be
reparsed if the encoding changes. Perhaps everything but the file
parts of a multipart form could be saved in a buffer..? ie. you strip
out the large files from the input stream and leave the rest for
normal form processing.

Also watch out for which temp directory files are being spooled to. If
it is on a separate partition then the final rename() will actually be
a file copy.  Large files should probably be sent to a configured
spool directory.

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Following symbolic directory links with NaviServer possible?

2009-09-22 Thread Stephen Deasey
On Tue, Sep 22, 2009 at 1:13 PM, Christian A Vogl  wrote:
> Yes, you're right, Stephen, thank you!
>
> Responsible's my own ns_returnforbidden, and I was misguided by the
> different behaviour for files and directories. In detail, for maybe
> helping other misguided half-blinds like me:
>
> I checked file access using TCL's "file normalize",
> which returns
> ย  "/path/to/real/file.ext"
> for requests of "/path/to/webserver/pages/symdir/file.ext" in a
> symbolically linked directory (symbolic link
> ย  "symdir --> /path/to/real"
> in physical naviserver page root "/path/to/webserver/pages"),
>
> but returns
> ย  "/path/to/webserver/pages/physdir/file.ext"
> if only "file.ext" links symbolically somewhere else (symbolic link
> ย  "file.ext --> /path/to/real/file.ext"
> in physical directory "/path/to/webserver/pages/realdir")
>
>
> So I just had to drop the normalizing.


Check out ns_register_fasturl2file:

  http://naviserver.sourceforge.net/n/naviserver/files/ns_register_url2file.html

It's like the 'mount' command in linux, or like symlinking one
directory to another.

Some examples (bit obscure...) here:

  http://bitbucket.org/naviserver/naviserver/src/tip/tests/url2file.test#cl-73

--
Come build with us! The BlackBerryยฎ Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Following symbolic directory links with NaviServer possible?

2009-09-22 Thread Stephen Deasey
On Tue, Sep 22, 2009 at 11:23 AM, Christian A Vogl  wrote:
> Hi all!
>
> I'm wondering if it's a misconfiguration of mine or a feature of
> NaviServer:
>
> whenever I want to symbolically link to a folder in "pages" directory,
> I run into a 403 ("Forbidden") error.
>
> Symbolically linking to individual files works fine.
> Did I miss a configuration parameter?


I don't think there's any code in the fastpath (static files) or
adp/tcl path which returns a 403 response.

Maybe you have some code which calls ns_forbidden or
Ns_ConnReturnForbidden? In a filter, or a directory listing proc/adp?

If there is also a file/directory permission error, it should show up
in the error log.

--
Come build with us! The BlackBerryยฎ Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


[naviserver-devel] Migrating aol.com from proprietary platform (AOLserver) to Open Source

2009-07-13 Thread Stephen Deasey
Some pretty funny miss-statements in this history of AOLserver running aol.com:

http://velocityconference.blip.tv/file/2286110/


But the punchline is that their shiny new apache/tomcat setup can
barely manage half the 45 reqs/sec she derides the old AOLserver on 6
year old hardware achieving.


The other videos from this conference are actually interesting -- check 'em out.

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] DB Connection Handles nsdbipg

2009-03-26 Thread Stephen Deasey
On Thu, Mar 26, 2009 at 3:09 PM, Ian Harding  wrote:
> Please ignore, it is a permission issue. ย The user had not rights in
> the schema, and since I used search_path, it didn't generate a
> permission denied error, it just didn't look there and generated a
> does not exist error.


Great.


FYI, there is some extra debug output available if you enable
server-wide debug logging. Each handle has an id and much of the log
output shows the id and the number of queries performed.  In this
case, you'd want to make sure that the same handle is being used for
both the SET command and the following query.

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] DB Connection Handles nsdbipg

2009-03-25 Thread Stephen Deasey
On Wed, Mar 25, 2009 at 10:56 PM, Ian Harding  wrote:
> I am in a situation where I'd like to be able to set the search_path
> on each page request. ย In AOLServer I would have just made a db handle
> getter function that would call ns_db gethandle, issue a quick SET
> command, and pass the handle back to the caller.
>
> With nsdbipg I don't know how to do this. ย There doesn't seem to be an
> explicit getting of a handle. ย It seems that they are gotten
> automatically on each call and released on each call to a nsdbi
> function.


Handles are managed automatically by default, but you can extend the
lifetime with the eval command:

dbi_eval {
dbi_dml {set search_path to foo, public}
set users [dbi_rows {select * from users}]
}

When you don't pass the -transaction switch, you are simply reusing
the same handle.


> Maybe the datasource param can contain a schema setting, but even that
> would not be what I want. ย I want to be able to set the path ideally
> on each connection, or on each call to the nsdbi functions.


Do you want to set the path for the lifetime of the *database*
connection, or are you trying to create 'virtual' users with one
database pool, switching the schema search path for duration of the
*http* connection?

If it's the first, you could set the default path in the postgresql.conf file:

search_path = '$user, public'

If it's the second, then maybe something like the above db_eval will
work for you.

You could wrap it up in a command like:

with_schema foo {
dbi_rows { ... }
}

Alternatively, you could set the max number of handles to 0, in which
case the driver switches to handle-per-thread mode (See docs).  In
this case, when each command 'gets' a handle it will always get the
same one, as it is never actually returned to the pool but cached for
the thread.  The idea behind this was as a performance optimisation
for the case where pretty much all your conn threads perform queries
and getting and putting is just overhead. But it would allow you in
this case to set the schema path at the beginning of the http request
and have it persist.

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] AOLserver/Naviserver in Tcl/Tk Google Summer of Code 2009 effort

2009-03-13 Thread Stephen Deasey
On Thu, Mar 12, 2009 at 11:06 PM, Tomasz Kosiak  wrote:
> Hi!
>
> Is there someone interested to be a mentor from AOLserver/Naviserver
> community within Tcl GSoC 2009 effort? Do you have any well defined
> project ideas which could be written down at http://wiki.tcl.tk/22182.
>
> As Matthew mentioned last year Tcl acted as umbrella organization for
> Tcl/Tk/AOLserver/OpenACS/XOTcl and we were given 9 slots which IMHO
> shows that this is the right direction.
>
> We did one AOLserver and one XOTcl project which were somehow OpenACS related.


What was the result of the AOLserver project?

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Mercurial help

2009-03-11 Thread Stephen Deasey
On Wed, Mar 11, 2009 at 5:09 PM, Vlad Seryakov  wrote:
> yes, no history yet, i was doing baby steps


Oh OK.  I'll let you play with it.

Note though that mercurial history is immutable. You will have to
delete the repos and convert again.


> I used my bitbucket name, it is vseryakov, on SF it was taken, so SF name is 
> just seryakov :-((


There's two names here: your bitbucket username, which mercurial
doesn't know or care anything about, and the name you add to the
commit log.

This last one can be absolutely anything you like: seryakov,
vseryakov, sdeasey... mercurial enforces nothing. But by convention
it's your name and email address, and you keep it consistent so it
doesn't look like there's two of you :-)

Just add:

[ui]
username=Vlad Seryakov 

to ~/.hgrc and forget about it.


When converting repos from CVS you need to map the old-style SF
username into a new-style mercurial name/email.

I did it like this:

hg convert -A ~/tmp/sf.authors \
   --config convert.hg.usebranchnames=0 \
   --config convert.hg.clonebranches=1 \
   ~/in/naviserver-modules-HEAD/nsudp/ nsudp-CVSROOT-hg

and in sf.authors are lines like:

    seryakov=Vlad Seryakov 



> Stephen Deasey wrote:
>> On Wed, Mar 11, 2009 at 3:10 AM, Vlad Seryakov  
>> wrote:
>>> imported all
>>>
>>> i skipped nsffmpeg, nsotcl, nstcp, i will not going to support themand
>>> they will not compile, so no point keeping broken things.
>>>
>>> nsocaml still may be of interest even it is not compiling as it is now.
>>
>>
>> Hmm, they all just say 'Initial import', you didn't import the
>> history. And you changed your name again, so there's about 3 'yous' on
>> there now.
>>
>> I'll convert them -- there's only 9.
>>
>> --
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> ___
>> naviserver-devel mailing list
>> naviserver-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>>
>
> --
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> ___
> naviserver-devel mailing list
> naviserver-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Mercurial help

2009-03-11 Thread Stephen Deasey
On Wed, Mar 11, 2009 at 3:10 AM, Vlad Seryakov  wrote:
> imported all
>
> i skipped nsffmpeg, nsotcl, nstcp, i will not going to support themand
> they will not compile, so no point keeping broken things.
>
> nsocaml still may be of interest even it is not compiling as it is now.


Hmm, they all just say 'Initial import', you didn't import the
history. And you changed your name again, so there's about 3 'yous' on
there now.

I'll convert them -- there's only 9.

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Mercurial help

2009-03-10 Thread Stephen Deasey
On Tue, Mar 10, 2009 at 4:41 PM, Stephen Deasey  wrote:
> On Tue, Mar 10, 2009 at 4:14 PM, Vlad Seryakov  
> wrote:
>> Stephen,
>>
>> Can you describe how to import module into hg on bitbucket, it keeps saying 
>> i am not authorized.
>
>
> Log in as 'naviserver' at bitbucket.org.
>
> Got to:
>
> ย  ย http://bitbucket.org/repo/create
>
> Fill out the info. ย Once created, in the admin tab, on the right hand
> side under Permissions -> Administrators ย add verseryakov and whoever
> else you'd like.
>
> Back on your machine...
>
> You can now clone the repo from bitbucket to your machine if you like,
> and commit straight into it -- the repo url will be set correctly for
> you.
>
> As a shortcut, you can add something like this to your ~/.hgrc file:
>
> ย  ย [paths]
> ย  ย nsfoo = https://vserya...@bitbucket.org/naviserver/nsfoo/
>
> this allows you to refer to the repo on bitbucket as 'nsfoo' on the
> command line. So, if you've converted one of the remaining repos and
> you want to push it, without first cloning from bitbucket, you just:
>
> ย  ย cd ~/nsfoo-hg
> ย  ย hg outgoing nsfoo
> ย  ย hg push nsfoo
>
> The 'outgoing' tells you what it would push without actually pushing.
>
> If you edit the ~/nsfo-hg/.hg/hgrc to add:
>
> ย  ย [paths]
> ย  ย default = http://bitbucket.org/naviserver/nsfoo
>
> you don't have to tell it where you want to push to. Just:
>
> ย  ย cd ~/nsfoo-hg
> ย  ย hg push
>
>
> Once it's up there, *then* you can customise the rest of the Admin
> options on bitbucket -- set up the commit emails etc. (look at
> naviserver for an example). Do this second so you don't spam the list
> with 5 years of history :-)
>
>
> I've converted some more modules. ย Here's what's left to do:
>
> nsconf
> nsexpat
> #nsstats
> nssys
> nstk
> nszlib
>
> nsffmpeg
> nsfortune
> nsocaml
> nsotcl
> nssavi
>
> nsdbext
> nsdbpd
>
>
> I know you said some where perhaps obsolete now, but what they hey,
> better not to loose them.
>
> You could leave nsdbext and nsdbpd for me if you like. I was going to
> try merging in the whole aolserver history, which is a little more
> work.
>


Oh yeah, if anyone has a few spare minutes you could add the missing
modules to ohloh:

   https://www.ohloh.net/tags/naviserver

Then we can link them up in the Tcl wiki and embed the ohloh graphs 'n stuff.

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Mercurial help

2009-03-10 Thread Stephen Deasey
On Tue, Mar 10, 2009 at 4:14 PM, Vlad Seryakov  wrote:
> Stephen,
>
> Can you describe how to import module into hg on bitbucket, it keeps saying i 
> am not authorized.


Log in as 'naviserver' at bitbucket.org.

Got to:

http://bitbucket.org/repo/create

Fill out the info.  Once created, in the admin tab, on the right hand
side under Permissions -> Administrators  add verseryakov and whoever
else you'd like.

Back on your machine...

You can now clone the repo from bitbucket to your machine if you like,
and commit straight into it -- the repo url will be set correctly for
you.

As a shortcut, you can add something like this to your ~/.hgrc file:

[paths]
nsfoo = https://vserya...@bitbucket.org/naviserver/nsfoo/

this allows you to refer to the repo on bitbucket as 'nsfoo' on the
command line. So, if you've converted one of the remaining repos and
you want to push it, without first cloning from bitbucket, you just:

cd ~/nsfoo-hg
hg outgoing nsfoo
hg push nsfoo

The 'outgoing' tells you what it would push without actually pushing.

If you edit the ~/nsfo-hg/.hg/hgrc to add:

[paths]
default = http://bitbucket.org/naviserver/nsfoo

you don't have to tell it where you want to push to. Just:

cd ~/nsfoo-hg
hg push


Once it's up there, *then* you can customise the rest of the Admin
options on bitbucket -- set up the commit emails etc. (look at
naviserver for an example). Do this second so you don't spam the list
with 5 years of history :-)


I've converted some more modules.  Here's what's left to do:

nsconf
nsexpat
#nsstats
nssys
nstk
nszlib

nsffmpeg
nsfortune
nsocaml
nsotcl
nssavi

nsdbext
nsdbpd


I know you said some where perhaps obsolete now, but what they hey,
better not to loose them.

You could leave nsdbext and nsdbpd for me if you like. I was going to
try merging in the whole aolserver history, which is a little more
work.

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: Vlad Seryakov : Added call to nsproxy Tcl_FindExecutable(argv[0]); to keep Tcl 8.5 from crashing in thread related initialization.

2009-03-10 Thread Stephen Deasey
On Sun, Mar 8, 2009 at 4:13 PM,   wrote:
> 1 new changeset in naviserver:
>
> http://www.bitbucket.org/naviserver/naviserver/changeset/4b0584c5e64b/
> changeset: ย  r2184:4b0584c5e64b
> user: ย  ย  ย  ย Vlad Seryakov
> date: ย  ย  ย  ย 2009-03-08 17:12:53
> summary: ย  ย  Added call to nsproxy Tcl_FindExecutable(argv[0]); to keep Tcl 
> 8.5 from crashing in thread related initialization.


Already present...

  
http://bitbucket.org/naviserver/naviserver/src/4b0584c5e64b/nsproxy/nsproxylib.c#cl-432

--
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] SLS

2009-03-02 Thread Stephen Deasey
On Mon, Mar 2, 2009 at 6:31 PM, Vlad Seryakov  wrote:
> I am working with persistent connections right now and want to track when the 
> socket is closed to cleanup some memory in
> Tcl but it looks like there is no way to call cleanup Tcl proc on socket 
> close. I am thinking to extend ns_sls to attach
> Tcl proc to be called at cleanup stage.
> Is this right thing to do?


What else have you had to modify to create persistent connections -- a
new driver?  You could run cleanup callbacks from your
Ns_DriverCloseProc.

Also, in what thread do you expect callbacks to run? In which thread
are the sockets being held open?

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Buglets

2009-02-23 Thread Stephen Deasey
On Mon, Feb 23, 2009 at 10:12 PM, Ian Harding  wrote:
> Here are a couple things I've found during my migration from AOLServer
> to Naviserver.
>
> 1. ย The order of arguments to ns_register_filter is reversed. ย I found
> a discussion in the archives talking about this, but no conclusion.
> It looks like the procedure args and the filter reason got switched,
> which is fine. ย I just didn't know.


It's like I'm psychic:

  http://wiki.tcl.tk/22567

:-)


> 2. ย dbipg does something strange when used with a template, and a
> column the same name as the table. ย This works as expected:
>
> default:nscp 1> dbi_rows {SELECT classification FROM classification}
> UNCLASSIFIED
>
> This does not:
>
> default:nscp 2> dbi_rows {select classificationid, classification from
> classification} {
> default:nscp 2>>> $classificationid -> $classification
> default:nscp 2>>> }
>
> 1 -> 1


This works for me, if I'm reading your example right. I've added a
test; can you try it out on your machine?

http://bitbucket.org/naviserver/nsdbipg/changeset/0fae5f9a2fb9/


> 3. ย ns_cp is broken. ย I read in the archives that this command was to
> be deprecated. ย So I quit using it. ย What it did was fail with a
> permission error which is funny because [exec cp ...] did not fail.
> Maybe those commands should just be removed.


Can you add a test which fails to tests/compat.test?

http://bitbucket.org/naviserver/naviserver/changeset/43cbf8f4f8ae/


Here are some tips for testing naviserver:

http://wiki.tcl.tk/21659



> There is going to be some pain migrating anyway...


Hope not.  If you run into anything, remember to add it to the wiki.

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Wiki Account

2009-02-19 Thread Stephen Deasey
On Thu, Feb 19, 2009 at 4:10 PM, Vlad Seryakov  wrote:
> Ian Harding wrote:
>> Hi,
>>
>> Can I have an account on the wiki?
>>
>> Thanks!
>
> It was long time ago i used but now i always get this error even if i logged 
> in. In my opinion, this Wiki is no-use
>
> Sorry! We could not process your edit due to a loss of session data. Please 
> try again. If it still doesn't work, try
> logging out and logging back in.
>
> We've been using pmwiki for a long time under Naviservr with nsphp, this is 
> very simple and fast and powerful wiki, no
> need for database, just one dir with .php files. I'd vote for it, mediawiki 
> is too complex for occasional edits and the
> syntax i forget completely if do not use it for some time. pmwiki syntax is 
> much more simpler.


How about using the Tcl wiki?

  http://wiki.tcl.tk/naviserver

One advantage is that it has a critical mass of users, so that even
without requiring sign-up before editing there does not seem to be a
spam problem.  That's going to be tough to achieve in a stand-alone
wiki. (I think the spam on ours tired every one out).

Here's a list of all the pages on the current wiki:

  http://naviserver.sourceforge.net/w/Special:Allpages

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Session module

2009-02-16 Thread Stephen Deasey
On Sun, Feb 15, 2009 at 6:55 PM, Ian Harding  wrote:
> Hello,
>
> I am migrating to Naviserver from AOLServer mostly because of the
> excellent nsdbi module.
>
> My existing code is depended on the nssession module
> http://bas.scheffers.net/aolserver/ .   It doesn't compile and run
> unmodified under Naviserver, but before I start hacking on it, is
> there an existing session module or a tcl solution that someone else
> has already written?
>


I'm not sure that it's worth porting that module. The cache locking is
broken, the file handling looks dodgy, and in general it has some odd
ideas about configuration and string handling.

If all you need to do is replicate some ns_session Tcl commands so
your existing code works then the easiest way would be to create a
work-alike using the existing naviserver Tcl commands:

  * cookie handling: naviserver has this built in:
http://naviserver.sourceforge.net/n/naviserver/files/ns_cookie.html

  * caching: also now built in:
http://naviserver.sourceforge.net/n/naviserver/files/ns_cache.html

  * persisting the session: just use nsdbi, if you're already using
it. If you really want
to use the file system, use ns_hashpath in nsd/pathname.c to
prevent enormous
directories from bogging down the server.

  * ns_rand: already exposed.


It will be more robust than than the C nssession module, and almost
certainly faster too.


If you want to create something fancier as a C module, I'd be
interested in helping.

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Release

2009-02-09 Thread Stephen Deasey
On Tue, Feb 10, 2009 at 1:04 AM, Ian Harding  wrote:
> Ah, I think I found it. ย Never mind my question.

Hoping you found autogen.sh...

(Only needed when checking out from the repository to bootstrap the
automake stuff).

--
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Config error

2009-02-05 Thread Stephen Deasey
On Thu, Feb 5, 2009 at 7:28 PM, Vasiljevic Zoran  wrote:
>
> On 05.02.2009, at 20:30, Vlad Seryakov wrote:
>
>> simple macro like #define NS_STR(s)  (s != NULL ? s : "")
>> can be used instead of using ?: every time
>
> I buy that.


I dunno, seems a bit gratuitous. You can't tell what the code does
just by looking at it, and maybe the default shouldn't be "" ?

Maybe it's just a code formatting issue:


>> Ns_Log(Dev, "config: %s:%s value=\"%s\" default=\"%s\" (string)",
>>section, key, value, def);
>
> should be changed to something like
>
>> Ns_Log(Dev, "config: %s:%s value=\"%s\" default=\"%s\" (string)",
>>section ? section : "", key, value ? value : "", def ? def : "");


If we limit ourselves to gcc:


Ns_Log(Dev, "config: %s:%s value=\"%s\" default=\"%s\" (string)",
section ?: "", key, value ?: "", def ?: "");


(Our Windows build works with gcc only now, I think).

--
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Config error

2009-02-05 Thread Stephen Deasey
On Thu, Feb 5, 2009 at 5:21 PM, Vasiljevic Zoran  wrote:
>
> On 05.02.2009, at 18:14, Vlad Seryakov wrote:
>
>> The reason i think because Ns_DStringPrintf now uses OS's snprintf,
>> before that it uses home-grown sprintf-like engine.


Yeah, all uses of printf-like functions throughout the code base need
to be checked. I know at least I've been sloppy about this.


> Most probably. But that will not help us of course.
> I will need to learn this brave new code
> repository thing...


Don't forget to sign up with bitbucket.org and tell me your username.

You'll be able to clone (checkout) and commit (locally) no problem as
is, but you need to be authorized to push back.

--
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] nsdbi 0.2 released

2009-02-04 Thread Stephen Deasey
On Wed, Feb 4, 2009 at 2:37 PM, Ian Harding  wrote:
> On Wed, Jun 11, 2008 at 3:43 AM, Stephen Deasey  wrote:
>> Changes and downloads:
>>
>>
>> http://sourceforge.net/project/shownotes.php?release_id=605838&group_id=130646
>>
>
> I just discovered this, and it's all I need to decide to jump to
> Naviserver from AOLServer.


Great.

How did you eventually find it?  (just wondering...)

--
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: groks: Manage lifetime of tcl synchronization objects without trampling memory -- -- The old scheme with both anonymous and named locks was makinf it difficul

2008-12-01 Thread Stephen Deasey
On Tue, Dec 2, 2008 at 3:33 AM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> Stephen,
>
> Will it be too much to ask just to add all existing modules into
> Mercurial, frankly i would like to do it but just my mind on something
> else right now. At the same time i will start using Naviserver big time
> very soon and would like to have repository available for all bugfixes
> and improvements.


I already converted some:

  http://www.bitbucket.org/naviserver/

I'll do the rest, but if there's any that are particularly important
to you I'll do them first.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: groks: Manage lifetime of tcl synchronization objects without trampling memory -- -- The old scheme with both anonymous and named locks was makinf it difficul

2008-11-25 Thread Stephen Deasey
On Tue, Nov 25, 2008 at 8:15 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> Ok, just to confirm
>
> what about CVS? should we disable it? clear description then should be made 
> how to get sources from new repo


Yeah that needs to be done too.

Convert all the modules to their own repos.

Make a backup of CVS and stick it on the download section.

Dissable CVS in the sourceforge interface.

Fixup the README file etc. on how to get the new source.


Converting the repos isn't hard but I like to clean them up too. I
think I described how to do it before, so you can give it a go if you
feel like it. Ask if you need help.  Otherwise, I'll just start
converting them.


> Stephen Deasey wrote:
>> On Tue, Nov 25, 2008 at 1:28 AM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>>> That means all development from now on goes to Mercurial, Right?
>>
>>
>> Well no one complained so I guess that means we've switched.
>>
>> I'll convert the other modules...
>>
>> -
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> ___
>> naviserver-devel mailing list
>> naviserver-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>>
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> naviserver-devel mailing list
> naviserver-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] commit/naviserver: groks: Manage lifetime of tcl synchronization objects without trampling memory -- -- The old scheme with both anonymous and named locks was makinf it difficul

2008-11-25 Thread Stephen Deasey
On Tue, Nov 25, 2008 at 1:28 AM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> That means all development from now on goes to Mercurial, Right?


Well no one complained so I guess that means we've switched.

I'll convert the other modules...

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] make memcheck / valgrind

2008-11-21 Thread Stephen Deasey
On 11/21/08, Bernd Eidenschink <[EMAIL PROTECTED]> wrote:
>
>  > No no. Errors are bad, there should be none.
>  >
>  > Stop teasing and show us them...   :-)
>
>
> Here you go:
>  http://www.kinetiqa.de/naviserver/memcheck.log.txt
>
>  TCL: 8.4.19 sources


This is weird, 8.4 also has errors? (you were using 8.5.5 before?)

8.4.19 works for me.

Are you compiling 32bit on a 64bit linux box?


Anyway, these kinds of things are usually errors (the message is from valgrind):

==18662== Invalid read of size 4
==18662==at 0x40151E3: (within /lib/ld-2.7.so)
==18662==by 0x4005C59: (within /lib/ld-2.7.so)
==18662==by 0x4007A87: (within /lib/ld-2.7.so)
==18662==by 0x4011533: (within /lib/ld-2.7.so)
==18662==by 0x400D5C5: (within /lib/ld-2.7.so)
==18662==by 0x4010F4D: (within /lib/ld-2.7.so)
==18662==by 0x41E9C18: (within /lib/tls/i686/cmov/libdl-2.7.so)
==18662==by 0x400D5C5: (within /lib/ld-2.7.so)
==18662==by 0x41EA2BB: (within /lib/tls/i686/cmov/libdl-2.7.so)
==18662==by 0x41E9B50: dlopen (in /lib/tls/i686/cmov/libdl-2.7.so)
==18662==by 0x41CF245: TclpDlopen (tclLoadDl.c:78)
==18662==by 0x419195C: Tcl_FSLoadFile (tclIOUtil.c:2791)
==18662==  Address 0x4fd2fc0 is 32 bytes inside a block of size 35 alloc'd
==18662==at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==18662==by 0x4006FC4: (within /lib/ld-2.7.so)
==18662==by 0x40079C9: (within /lib/ld-2.7.so)
==18662==by 0x4011533: (within /lib/ld-2.7.so)
==18662==by 0x400D5C5: (within /lib/ld-2.7.so)
==18662==by 0x4010F4D: (within /lib/ld-2.7.so)
==18662==by 0x41E9C18: (within /lib/tls/i686/cmov/libdl-2.7.so)
==18662==by 0x400D5C5: (within /lib/ld-2.7.so)
==18662==by 0x41EA2BB: (within /lib/tls/i686/cmov/libdl-2.7.so)
==18662==by 0x41E9B50: dlopen (in /lib/tls/i686/cmov/libdl-2.7.so)
==18662==by 0x41CF245: TclpDlopen (tclLoadDl.c:78)
==18662==by 0x419195C: Tcl_FSLoadFile (tclIOUtil.c:2791)



>  BTW: "make install" fails because of "install-docs" in Makefile,
>  maybe it would make sense to change the Makefile to be more
>  aware of missing "dtplite"-missing situations.


The idea is that if you are building from a released tarball then the
built documentation is included and you don't need dtplite. If you're
building direct from the repo, you need dtplite (and autoconf, etc.).


>  Nice: The ns_thread.test(s) double the memory usage, saturate my box with
>  100% CPU load... but, once done, all falls back to where it started.


Well at least something's working!

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] nsdbpg

2008-11-21 Thread Stephen Deasey
On 11/21/08, Bernd Eidenschink <[EMAIL PROTECTED]> wrote:
>
>  I'm cursed. I never can compile a postgres driver for naviserver
>  from scratch.
>
>  Here's my tale - maybe you can hint me to an obvious mistake:
>
>  I compiled a Postgres 8.2.11 from source into
>  /opt/pgsql8.2.11
>
>  Then I checked out /modules/nsdbpg.
>
>  I changed in the Makefile the line
>  MODLIBS= -lnsdb -lpq


You shouldn't need to edit the Makefile.

NAVISERVER points to the base of your naviserver install, and
POSTGRES points the base of your postgres install.

So,

$ make NAVISERVER=/usr/local/ns POSTGRES=/opt/pgsql8.2.11


(The Makefile uses -rpath to embed the location of postgres into
nsdbpg, so you shouldn't need to use LD_LIBRARY_PATH)

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Chnaged my mind: switch to mercurial

2008-11-20 Thread Stephen Deasey
On 11/20/08, Vasiljevic Zoran <[EMAIL PROTECTED]> wrote:
>
>  On 20.11.2008, at 20:33, Stephen Deasey wrote:
>
>  >
>  > And clean your finger nails, and brush your teeth, and say your
>  > prayers...
>
>
> Eh... brave new world...
>
>  So yet another thing to learn... I guess Internet is full of docs
>  about this and I will have fun reading it.


Hopefully, it will take you about 2 minutes to get the basics, which
is the advantage of mercurial over git, an otherwise great system.

Clone the repository first. You need the bits on your hard drive:


$ hg clone https://[EMAIL PROTECTED]/naviserver/naviserver/
$ cd naviserver

... hack hack hack...

$ hg commit
$ hg push


Now obviously there are bells n' whistles, but the basics are easy
enough that it shouldn't prevent you from getting things done.


(The built-in help is excellent: hg help, hg pull --help, etc.)

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Chnaged my mind: switch to mercurial

2008-11-20 Thread Stephen Deasey
On 11/20/08, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> vseryakov is my username,


OK. I've given you write access.


>  looks oike adding openssh pub key does not work, it keeps saying SSH key is 
> not valid


Perhaps during cut 'n paste a stray \n crept in?  Worked for me.

Anyway, you don't need to use ssh, ssl works just as well (http is
mercurial's native transport):

$ hg clone https://[EMAIL PROTECTED]/naviserver/naviserver/
~/in/naviserver-hg



btw. it seems that the bitbucket site is set up such that all repos
belong to a person, so for the naviserver repo I created a 'fake'
person 'naviserver' to own it. I'll send you and Zoran the password,
in case I'm run over by a walrus or something.

You won't need to use it on a day to day basis. It's just for adding
more people to the commit list and changing the details on the
website.


Also, make sure you have this in your ~/.hgrc

[ui]
username=Vlad Seryakov <[EMAIL PROTECTED]>

so that it matches all the other log entries, otherwise you'll be
[EMAIL PROTECTED] or whatever.

And for log messages note that the convention is to have a single
line, like an email subject, then a blank line, then any extra
explanation, in normal paragraphs. Word wrap to 70-80 characters. Use
active voice, 'fix' rather than 'fixed'. No full stop. if it's a
module, prefix with 'nsperm: ' or whatever. Check what's there
already, you'll get the idea. And because commit and push are
separate, you can check and redo as many times as you like before
anything is public.

If you find yourself trying to describe two things, they should have
been separate commits. Mercurial makes this easy. You can commit
multiple times, and then at the end push to the public repo.

And clean your finger nails, and brush your teeth, and say your prayers...

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] make memcheck / valgrind

2008-11-20 Thread Stephen Deasey
On Thu, Nov 20, 2008 at 8:46 AM, Bernd Eidenschink <[EMAIL PROTECTED]> wrote:
>> > ==3781== ERROR SUMMARY: 18 errors from 9 contexts (suppressed: 106 from
>> > 1)
>>
>> This is the important bit. There should be no errors. Scroll back up
>> the log output and you should see details of the errors. Unlike the
>> summary, valgrind outputs these as they happen.
>>
>> I haven't tested against 8.5 in a long time, so I just tried it.
>
> Compiling 8.5 was just out of curiosity. I memchecked both 8.5 and 8.4 (latest
> sources) on naviserver trunk code and had errors with both.
>
> Doesn't matter to me as I just need a running server (and the initial impulse
> for make memcheck was just my test with vtmalloc.).
> I was just curious if the result is somewhat normal, as memcheck runs all the
> tests and one or more of them might intentionally peek and poke.
> (I didn't do one single click, just watched what make memcheck runs until it
> presents the results).
>
> So the result: Using trunk naviserver source code, using latest TCL 8.4 source
> code, compiling and memchecking spits out errors that can be ignored, unless
> barking in uppercase letters or freezing the os :-)
>

No no. Errors are bad, there should be none.

Stop teasing and show us them...   :-)


( Make sure you compile Tcl and naviserver with --enable-symbols )

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Changed my mind: switch to mercurial

2008-11-19 Thread Stephen Deasey
On Wed, Nov 19, 2008 at 6:54 PM, Andrew Piskorski <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 05:48:11PM +, Stephen Deasey wrote:
>
>>   http://www.bitbucket.org/naviserver/naviserver/overview/
>
>> It's up to date for both branches of AOLserver, and naviserver with
>> the exception of Zoran's commit the other day (I'll update that
>> now).  It also models the fact that naviserver is a fork AOLserver
>> 4.0.10.
>
> I've yet to really use Mercurial at all, but that all sounds very
> cool.
>
> I take it that one way CVS to Mercurial importing is very robust by
> now?


It is. Here's the command I use:

$ hg convert -A ~/authors.map \
  --config convert.hg.usebranchnames=0 --config convert.hg.clonebranches=1 \
  ~/in/naviserver-HEAD ns-HEAD-hg

Where authors.map is a file which maps sf username like 'sdeasey' to
mercurial users like 'Stephen Deasey <[EMAIL PROTECTED]>', and the
branch stuff is saying I prefer to represent branches as separate
repos.


However, I have done a bunch of clean ups of the commit messages, some
squashing of commits which should have been one commit, or where a
followup commit fixed a typo or some other trivial mistake with a log
message of 'oops...'.

So the conversion is 'accurate', but better than the original :-)

Even if you're not interested in mercurial, you might want to browse
the aolserver repos here for this reason alone:

  http://www.bitbucket.org/aolserver/aolserver/overview/
  http://www.bitbucket.org/aolserver/aolserver-40x/overview/

For example, according to the AOLserver ChangeLog the last change was
made in June, and it's one of only two changes made this year:

  
http://aolserver.cvs.sourceforge.net/viewvc/aolserver/aolserver/ChangeLog?revision=1.386&view=markup

Browsing the mercurial shortlog on bitbucket you can see there's
actually been 9 changes by 4 different authors.

This would be useful for these guys:

  http://openacs.org/forums/message-view?message_id=2438982

to whom it looks, on the outside, like nothing's been touched in
either aolserver or naviserver for years...

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


[naviserver-devel] Chnaged my mind: switch to mercurial

2008-11-19 Thread Stephen Deasey
On Wed, Aug 20, 2008 at 7:16 AM, Vasiljevic Zoran <[EMAIL PROTECTED]> wrote:
>
> On 20.08.2008, at 00:19, Stephen Deasey wrote:
>
>> I think it's probably better to stay with the familiar cvs. It doesn't
>> scare anyone, SF handles everything, and patches are probably too
>> infrequent to for the vcs to make much difference anyway.
>>
>> Agree?
>
> Yes. Lets keep it simple for now.
>


I've changed my mind about this again. It's just too much of a pain in
the ass to do anything more than minor fixes without trampling on
other peoples stuff, using CVS.

Here's something new though:

  http://www.bitbucket.org/naviserver/naviserver/overview/

Fancy hosting for mercurial repos. It's like github (if you're
familiar with that, very popular), but for mercurial. It's up to date
for both branches of AOLserver, and naviserver with the exception of
Zoran's commit the other day (I'll update that now).  It also models
the fact that naviserver is a fork AOLserver 4.0.10.

This would have all the advantages we talked about previously, plus a
couple of new ones which would be particularly helpful when developing
larger changes which need a bit of back and forth development before
being committed: branches a patch queues.

If you look at the interface you'll see a 'fork' link. The idea is any
random stranger can fork any project to make changes. They then send a
pull request to you and merge the changes back, and they delete their
fork.  Bitbucket also supports mercurial queues, which is almost the
same but a bit easier when reworking a set of patches.

So the ideas is that we'd use bitbucket for hosting the mercurial
repos and keep everything else as is.

How does this sound?


(Tell me you username on bitbucket and I'll add you to the project).

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] make memcheck / valgrind

2008-11-19 Thread Stephen Deasey
On Wed, Nov 19, 2008 at 3:45 PM, Bernd Eidenschink <[EMAIL PROTECTED]> wrote:
>> > But the results on my local box are... a little bit scary right now.
>>
>> ... scary is relative. So, how scary is your "scary", really?
>
> Scary for me, the ignorant :-)
>
>
> ==3781== ERROR SUMMARY: 18 errors from 9 contexts (suppressed: 106 from 1)


This is the important bit. There should be no errors. Scroll back up
the log output and you should see details of the errors. Unlike the
summary, valgrind outputs these as they happen.

I haven't tested against 8.5 in a long time, so I just tried it.

I always compile Tcl for testing with --enable-symbols=mem, which you
would think would interact badly with valgrind, but I've found it's
like a pig sniffing out truffles when it comes to buffer over runs and
depending on uninitialized memory. These are the kinds of errors
valgrind is talking about, in contrast to plain memory leaks which you
might expect to find.

Anyway, won't even run with 8.5.5 here:

[19/Nov/2008:16:48:33][26547.b7ff46c0][-main-] Fatal: expected to
create new entry for object map

Program received signal SIGABRT, Aborted.
0x00110416 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install gcc.i386 glibc.i686
(gdb) bt
#0  0x00110416 in __kernel_vsyscall ()
#1  0x00b42660 in raise () from /lib/libc.so.6
#2  0x00b44028 in abort () from /lib/libc.so.6
#3  0x00144f18 in Panic (fmt=0x2b0760 "expected to create new entry
for object map") at log.c:617
#4  0x0025fec7 in Tcl_PanicVA (format=0x2b0760 "expected to create new
entry for object map",
argList=0xbfc06694 "") at
/home/sd/src/tcl8.5.5/unix/../generic/tclPanic.c:93
#5  0x0025ffca in Tcl_Panic (format=0x2b0760 "expected to create new
entry for object map")
at /home/sd/src/tcl8.5.5/unix/../generic/tclPanic.c:132
#6  0x0025c7b6 in TclDbInitNewObj (objPtr=0x96b7220) at
/home/sd/src/tcl8.5.5/unix/../generic/tclObj.c:637
#7  0x0024b919 in Tcl_DbNewListObj (objc=1, objv=0xbfc06700,
file=0x2ac234
"/home/sd/src/tcl8.5.5/unix/../generic/tclFileName.c", line=787)
at /home/sd/src/tcl8.5.5/unix/../generic/tclListObj.c:239
#8  0x00227d72 in Tcl_FSJoinToPath (pathPtr=0x96e4b50, objc=0, objv=0x0)
at /home/sd/src/tcl8.5.5/unix/../generic/tclFileName.c:787
#9  0x0026639d in SetFsPathFromAny (interp=0x0, pathPtr=0x96e4b50)
at /home/sd/src/tcl8.5.5/unix/../generic/tclPathObj.c:2441
#10 0x00265e4b in TclFSSetPathDetails (pathPtr=0x96e4b50,
fsRecPtr=0x96b4640, clientData=0x0)
at /home/sd/src/tcl8.5.5/unix/../generic/tclPathObj.c:2203
#11 0x0024a1c3 in Tcl_FSGetFileSystemForPath (pathPtr=0x96e4b50)
at /home/sd/src/tcl8.5.5/unix/../generic/tclIOUtil.c:4437
#12 0x00248a63 in Tcl_FSGetCwd (interp=0x0) at
/home/sd/src/tcl8.5.5/unix/../generic/tclIOUtil.c:2736
#13 0x00148603 in SetCwd (path=0x96f53c8
"/home/sd/ns-scratch-hg/tests") at nsmain.c:1063
#14 0x00147c24 in Ns_Main (argc=8, argv=0xbfc06b74, initProc=0x8048636
) at nsmain.c:504
#15 0x0804862c in main (argc=Cannot access memory at address 0x67b3
) at main.c:64


Seems innocuous enough:

nsd/nsmain.c:

char *
SetCwd(char *path)
{
Tcl_Obj *pathObj;

pathObj = Tcl_NewStringObj(path, -1);
Tcl_IncrRefCount(pathObj);
if (Tcl_FSChdir(pathObj) == -1) {
Ns_Fatal("nsmain: chdir(%s) failed: '%s'", path,
strerror(Tcl_GetErrno()));
}
Tcl_DecrRefCount(pathObj);
pathObj = Tcl_FSGetCwd(NULL);
if (pathObj == NULL) {
Ns_Fatal("nsmain: can't resolve home directory path");
}

return (char *)Tcl_FSGetTranslatedStringPath(NULL, pathObj);
}


Is this a bug though?  Can Tcl really expect to have never seen this
pointer before:

tcl8.5.5/generic/tclObj.c:

void
TclDbInitNewObj(
register Tcl_Obj *objPtr)
{
objPtr->refCount = 0;
objPtr->bytes = tclEmptyStringRep;
objPtr->length = 0;
objPtr->typePtr = NULL;

#ifdef TCL_THREADS
/*
 * Add entry to a thread local map used to check if a Tcl_Obj was
 * allocated by the currently executing thread.
 */

if (!TclInExit()) {
Tcl_HashEntry *hPtr;
Tcl_HashTable *tablePtr;
int isNew;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

if (tsdPtr->objThreadMap == NULL) {
tsdPtr->objThreadMap = (Tcl_HashTable *)
ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(tsdPtr->objThreadMap, TCL_ONE_WORD_KEYS);
}
tablePtr = tsdPtr->objThreadMap;
hPtr = Tcl_CreateHashEntry(tablePtr, (char *) objPtr, &isNew);
if (!isNew) {
Tcl_Panic("expected to create new entry for object map");
}
Tcl_SetHashValue(hPtr, NULL);
}
#endif /* TCL_THREADS */
}

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world

Re: [naviserver-devel] PHP streaming hangs

2008-11-08 Thread Stephen Deasey
On Sat, Nov 8, 2008 at 8:47 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>>
>> Do you need to buy into the full build process? Maybe you can just
>> pull in the header and link against the library..?
>
> The problem with PHP that it can support only one SAPI implementation
> and nsphp is not just extesion but SAPI handler, so just compiling it as
> extension will not work
>


There's an --enable-embed=shared option, and it seems to work (added).

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver ChangeLog,1.827,1.828

2008-11-08 Thread Stephen Deasey
On Sat, Nov 8, 2008 at 10:42 PM, Vlad Seryakov
<[EMAIL PROTECTED]> wrote:
> Update of /cvsroot/naviserver/naviserver
> In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26902
>
> Modified Files:
>ChangeLog
> Log Message:
> mark connection flags when last chunk is sent
>
>
> Index: ChangeLog
> ===
> RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v
> retrieving revision 1.827
> retrieving revision 1.828
> diff -C2 -d -r1.827 -r1.828
> *** ChangeLog   7 Nov 2008 19:01:57 -   1.827
> --- ChangeLog   8 Nov 2008 22:42:09 -   1.828
> ***
> *** 1,2 
> --- 1,7 
> + 2008-11-08  Vlad Seryakov <[EMAIL PROTECTED]>
> +
> +   * nsd/connio.c: Mark connection flags with NS_CONN_SENT_LAST_CHUNK
> +   when last chunk is actuall sent.
> +


What?


$ grep -r NS_CONN_SENT_LAST_CHUNK *

ChangeLog:   * nsd/connio.c: Mark connection flags with NS_CONN_SENT_LAST_CHUNK
include/ns.h:   #define NS_CONN_SENT_LAST_CHUNK0x100 /* Marks that
the last chunk was sent in chunked mode */
nsd/connio.c:  connPtr->flags |= NS_CONN_SENT_LAST_CHUNK;

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] PHP streaming hangs

2008-11-08 Thread Stephen Deasey
On Sat, Nov 8, 2008 at 5:00 AM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> Yes, keep-alive is the key, nshttp_test closes connection so it cannot
> test this

/*
 * php_ns_sapi_send_headers() flushes the headers to the client.
 * Called before real content is sent by PHP.
 */

static int php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
{
ns_context *ctx = SG(server_context);

if (ctx->conn != NULL) {
Ns_ConnSetResponseStatus(ctx->conn,
SG(sapi_headers).http_response_code);
}

Ns_ConnWriteData(ctx->conn, NULL, 0, NS_CONN_STREAM);

return SAPI_HEADER_SENT_SUCCESSFULLY;
}


Does this actually need to flush?

It depends when php calls it. In the case where there's no body, eg. a
302 redirect, then maybe this signals 'all done' and you're to write
the headers. In the case where there is a body it's not needed because
naviserver will construct and dump the headers when you try to write
the first data, and it will send both with a single syscall (and
packet, if it fits), which is more efficient.

So you should try not to flush. You might try to do nothing in this
call, and detect when you've finished sending in the case of a
zero-length body some other way. When php returns control to your
Ns_Op function you could check to see if any bytes were sent and if
not, flush the headers.

But anyway, you're checking for ctx->conn != NULL before setting the
response code, then using it unconditionally when you write the data.

Ns_ConnWriteData can fail but you're ignoring the return code and
returning success.




/*
 * php_ns_sapi_header_handler() sets a HTTP reply header to be sent to
the client.
 */


Does php try to set a length header? You may need to check for it in
here and call Ns_ConnSetLengthHeader.



/*
 * php_ns_sapi_ub_write() writes data to the client connection.
 */

static int php_ns_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
{
ns_context *ctx = SG(server_context);

if (!ctx->conn) {
int size = ctx->buffer ? strlen(ctx->buffer) : 0;
ctx->buffer = ns_realloc(ctx->buffer, size + str_length + 1);
strncpy(&(ctx->buffer[size]), str, str_length);
ctx->buffer[size + str_length] = 0;
return str_length;
}

if (Ns_ConnWriteData(ctx->conn, (void *) str, str_length,
NS_CONN_STREAM) != NS_OK) {
php_handle_aborted_connection();
}

return str_length;
}


Whether the write succeeds or fails, you're returning the original
buffer length, which I guess signals success to php. It might be hard
to figure out exactly how much did get sent, because
conn->nContentSent includes the headers bytes. But maybe php doesn't
care? You'll have to check if you can return -1 or 0 or something.

You might also want to check if php exposes it's buffering. If you can
figure out that your ub_write call is being called with all the data
that's going to be sent (the script has finished executing) or the
last piece of data, you shouldn't pass the flag NS_CONN_STREAM.
Otherwise, you should.



> I tried that but could not get it to work, it generates configure but
> when i run it i never could make it finish, there are always some errors.



Do you need to buy into the full build process? Maybe you can just
pull in the header and link against the library..?

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] PHP streaming hangs

2008-11-07 Thread Stephen Deasey
On Sat, Nov 8, 2008 at 3:38 AM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>
> Added, runs fine but that the thing, it hangs in firefox, not in the test
>


OK, so there's a difference.

Maybe keepalive -- you mentioned what looked like responses garbled
together? An HTTP 1.1 request will force keepalive:

test php-1.1 {sequential requests w/keepalive} -body {
foreach n {0 1 2} {
lappend results [nstest_http -http 1.1 \
 -getbody 1 \
 -getheaders content-length \
 GET /test.php]
}
set results
} -cleanup {
unset -nocomplain results
} -result "{200 10 {test page\n}} {200 10 {test page\n}} {200 10 {test page\n}}"



Also, can you adjust the build to use an already installed php? See:
README.SELF-CONTAINED-EXTENSIONS in the php source for directions.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] PHP streaming hangs

2008-11-07 Thread Stephen Deasey
On Fri, Nov 7, 2008 at 10:24 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:

> I want to find the problem and then will put test for future checks


No, you write the test to help find the bug.


> It is funny, using telnet and submitting same headers never triggers
> this, but when using firefox, after sevrral requests it hangs


Rather than typing the same thing into telnet over and over again, and
then repeating it with firefox, and then hoping other people can guess
right and reproduce what you're doing and have them repeat it all too,
why not check into CVS a 10 line test file?  It's just GOT to be
easier, right?

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] PHP streaming hangs

2008-11-07 Thread Stephen Deasey
On Fri, Nov 7, 2008 at 9:23 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>
> This is the simple PHP page that triggers hanging, when attached to the
> nsd, backtrace on all thread show they all are in the condwait or poll
> wait, seems like sent/expected bytes miscalculation.
>
> 
> $test = @$_COOKIE["test"];
> setcookie("test", "1", time() + 60, '/');
>
> if ($test == "1") {
>header("HTTP/1.0 304 Not Modified");
>exit();
> }
> ?>
> test page
>


Make a 'tests' directory and add the above snippet. Make it run from
'make test'.

The 'nsvfs' module in CVS is an example of an external module which
has tests using the nstest_http command. You could just 'cp -a
../nsvfs/tests tests' and then cut 'n paste from the Makefile.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver/nsd driver.c,1.119,1.120

2008-11-07 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 10:35 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
 static ssize_t
 Recv(Ns_Sock *sock, struct iovec *bufs, int nbufs, Ns_Time
 *timeoutPtr, int flags)
 {
 static const char request[] = "GET /whateva HTTP/1.0\r\n\r\n";
 size_t requestLen = sizeof(request);
 socklen_t sockLen = sizeof(struct sockaddr_in);

 memcpy(bufs->iov_base, request, requestLen);

 return recvfrom(sock->sock,
 bufs->iov_base + requestLen,
 bufs->iov_len - requestLen,
 0, (struct sockaddr*) &sock->sa, &size);
 }

 (checking for buffer lengths skipped here)


 The advantage of doing it this way is that everything is much simpler
 from the driver threads point of view. It doesn't need to know
 anything special about non-standard protocols, and there isn't
 anything in the driver callback api that isn't also useful to the HTTP
 server.
>>>
>>> Arguable this is not very clear and simple, driver will have to hack
>>> buffers and every request should pretend to be HTTP just so driver
>>> thread would think that it serves only HTTP requests.
>>
>>
>> It's clear and simple. It's maybe not very pretty :-)
>>
>>
>>> If we have special codes and already have 3, does another one breaks
>>> anythings if only one code makes overall process simpler not only in
>>> driver thread but for drivers itself?
>>
>>
>> It's a trade off.
>>
>> Either non-standard drivers prepend their first read with 20 bytes in Recv().
>> (~ two lines of code)
>>
>> *OR*
>>
>> You need to change all parts of the sever that expect an HTTP request
>> structure to be available. AND you need to account for the fact that
>> sometimes it gets created in the normal fashion, but other times it
>> gets created later, or not at all.
>>
>>
>> You've tried to ways to do this:
>>
>>
>> 1) Exposing a new Ns_DriverSetRequest routine.
>>
>> Here's what it looked like in nssyslogd:
>>
>> http://naviserver.cvs.sourceforge.net/viewvc/naviserver/modules/nssyslogd/nssyslogd.c?revision=1.18&view=markup
>>
>> NS_EXPORT int
>> Ns_ModuleInit(char *server, char *module)
>> {
>> ...
>> Ns_RegisterRequest(server, "SYSLOG",  "/", SyslogRequestProc,
>> NULL, srvPtr, 0);
>> ...
>> }
>>
>> static NS_DRIVER_ACCEPT_STATUS
>> Accept(Ns_Sock *sock, SOCKET listensock, struct sockaddr *sockaddrPtr,
>> int *socklenPtr)
>> {
>> sock->sock = listensock;
>> Ns_DriverSetRequest(sock, "SYSLOG / HTTP/1.0");
>> return NS_DRIVER_ACCEPT_DATA;
>> }
>>
>>
>> How is this functionally different to what I proposed (example in Recv 
>> above)?
>>
>>
>> 2) Doing away with the need for a Ns_Request all together.
>>
>> Which now looks like this:
>>
>> http://naviserver.cvs.sourceforge.net/viewvc/naviserver/modules/nssyslogd/nssyslogd.c?revision=1.19&view=markup
>>
>> NS_EXPORT int
>> Ns_ModuleInit(char *server, char *module)
>> {
>> ...
>> init.requestProc = Request;
>> ...
>> init.opts = NS_DRIVER_ASYNC | NS_DRIVER_NOPARSE;
>> ...
>> }
>>
>> static int
>> Request(void *arg, Ns_Conn *conn)
>> {
>> Ns_DString *dsPtr = Ns_ConnSockContent(conn);
>> SyslogRequest *req = SyslogRequestCreate(server, sockPtr->sock,
>> dsPtr->string, dsPtr->length, &sa);
>> SyslogRequestProcess(req);
>> ...
>> }
>>
>>
>> The strategy here seems to be to completely ignore the standard
>> request structure and do your own thing. There's nothing wrong with
>> this in the abstract -- you're not actually using any of the HTTP
>> stuff. However, the rest of the server fully expects the HTTP request
>> to be present and filled in, and this is why you've had to touch
>> dozens of files in dozens of places fixing up all code that might trip
>> over a null request field. (And the public API has changed...)
>>
>>
>> As far as I can see, neither method 1 or 2 achieves anything than
>> passing "METHOD / HTTP/1.0\r\n\r\n" does, using considerably less
>> code.
>>
>> For example, In the snippet above, you can see the newly added
>> Ns_ConnSockContent which returns a pointer to the read buffer (which
>> is otherwise private). Ordinarily the buffer would contain the HTTP
>> request line, any headers, then any body. You can get at the body with
>> the existing Ns_ConnContent. So if you just return "SYSLOG /
>> HTTP/1.0\r\n\r\n" and then your bytes in Recv(), the request would be
>> constructed and then you could parse the protocol beginning in the
>> body content.
>>
>
>
> I will try to take a look at this. ...
>


Did you take a look at this?  What do you think?

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=

Re: [naviserver-devel] modules/nsssl nsssl.c,1.6,1.7

2008-11-07 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 8:58 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> Stephen Deasey wrote:
>> On Wed, Oct 22, 2008 at 9:03 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>>> I tried to use Ns_SockSendBufs() but it sends data directly to socket
>>> where i need to send via driver's send proc.
>>
>>
>> Just pass your Send() proc directly, and delete SendBufs():
>>
>>  static ssize_t
>>  SendFile(Ns_Sock *sock, Ns_FileVec *bufs, int nbufs, Ns_Time
>> *timeoutPtr, int flags)
>>  {
>> -return Ns_SockSendFileBufsIndirect(sock->sock, bufs, nbufs,
>> timeoutPtr, flags, SendBufs);
>> +return Ns_SockSendFileBufsIndirect(sock->sock, bufs, nbufs,
>> timeoutPtr, flags, Send);
>>  }
>>
>>
>>> Why connPtr->nContentSent is not updated, all send called with conn
>>> parameters should do this
>>
>>
>> Yes, but Ns_ConnSend() is higher up the stack, so when sending data it
>> looks something like this:
>>
>> return.c: Ns_ConnReturnData
>> connio.c: Ns_ConnWriteData
>> connio.c: Ns_ConnWriteVData
>> connio.c: Ns_ConnSend
>> driver.c: NsDriverSend
>> nsssl/nsssl.c: Send
>>
>>
>> By the time your Send() is called we've already passed through
>> Ns_ConnSend(). nContentSent will be updated as the stack unwinds.
>>
>> If you call Ns_ConnSend() from within Send(), that's a loop...
>>
>
> The first argument is different, Ns_Sock vs SOCKET
>


Fixed. For SSL (and for all drivers) just leave sendfFileProc as NULL
and your sendProc will be called as needed to send file/buffer chunks.

If you were writing something like an FTP server, then you would want
to copy nssock and call Ns_SockSendFileBufs to optimise the
reading-from-disk/writing-to-network. Leaving it NULL will always be
correct though.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver/tcl fastpath.tcl,1.5,1.6

2008-11-07 Thread Stephen Deasey
On Fri, Nov 7, 2008 at 3:12 AM, Vlad Seryakov
<[EMAIL PROTECTED]> wrote:

> + # If address set to 0.0.0.0 in nssock to listen on
> + # all interfaces we may try to use Host: header to
> + # return proper urls
> + #
> +
> + if { $loc == "http://0.0.0.0"; } {
> +   set host [ns_set iget [ns_conn headers] Host]
> +   if { $host != "" } {
> + set loc http://$host
> +   }
> + }


You can't take unfiltered input from the host header and then feed it
back to ns_returnredirect as this vulnerable to a response splitting
attack.

  http://www.google.co.uk/search?q=response+splitting

It seems like this may be a more general kind of bug. After all, it's
not just in directory listings that 0.0.0.0 is an invalid host
address. Take a look at conn.c:Ns_ConnLocationAppend() -- looks like
this is where the fix needs to go.

This is a tricky are so add some extra tests in tests/ns_conn_host.test

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Relocating ns_atclose calls

2008-11-07 Thread Stephen Deasey
On Fri, Nov 7, 2008 at 4:32 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:

> In most cases ... it will work as before because
> atclose blocks and socket is not yet returned to driver


driver.c:NsSockClose() does return the Sock to the driver thread, and
it does not block.


> ... if i need to use socket garanteed at connection end, this is the
> only place i can do it.


Why? What are you trying to do?

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] nsphp and other broken things

2008-10-29 Thread Stephen Deasey
On Tue, Oct 28, 2008 at 5:02 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> After 2008-09-11, nsphp stopped working, even with the latest update to
> non-obsolete functions, it looks like something in the core flow,
> especially streaming part doe snot work properly.
>
> I tried all versions and the latest stable is marked in ChangeLog at
> 2008-09-11.
>
> This is only HTTP related and it could be problem in nsphp, but it was
> very stable until functions it used became obsolete. I started using
> Ns_ConnWriteData with or without NS_CONN_STREAM and browsers stopped
> showing web pages.
>
> These functions would tell that streaming is required and no
> Content-Length will be supplied:
>
> Ns_ConnSetRequiredHeaders(ctx->conn, ctype, -1);
> Ns_ConnFlushHeaders(ctx->conn, SG(sapi_headers).http_response_code);
>
> Then
> Ns_ConnWriteData without any flags would just send data to the browser
>
> In new code, the server does all things automatically but NS_CONN_STREAM
> flags is required to tell that we are streaming. Flush is not used
> anymore. When i telnet i get page back without content-length but still,
> every second request hangs or comes empty.
>


I'm not sure how you're triggering this. Can you write a test and
point me at it?

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver/nsd driver.c,1.119,1.120

2008-10-22 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 8:36 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>>
>> static ssize_t
>> Recv(Ns_Sock *sock, struct iovec *bufs, int nbufs, Ns_Time
>> *timeoutPtr, int flags)
>> {
>> static const char request[] = "GET /whateva HTTP/1.0\r\n\r\n";
>> size_t requestLen = sizeof(request);
>> socklen_t sockLen = sizeof(struct sockaddr_in);
>>
>> memcpy(bufs->iov_base, request, requestLen);
>>
>> return recvfrom(sock->sock,
>> bufs->iov_base + requestLen,
>> bufs->iov_len - requestLen,
>> 0, (struct sockaddr*) &sock->sa, &size);
>> }
>>
>> (checking for buffer lengths skipped here)
>>
>>
>> The advantage of doing it this way is that everything is much simpler
>> from the driver threads point of view. It doesn't need to know
>> anything special about non-standard protocols, and there isn't
>> anything in the driver callback api that isn't also useful to the HTTP
>> server.
>
>
> Arguable this is not very clear and simple, driver will have to hack
> buffers and every request should pretend to be HTTP just so driver
> thread would think that it serves only HTTP requests.


It's clear and simple. It's maybe not very pretty :-)


> If we have special codes and already have 3, does another one breaks
> anythings if only one code makes overall process simpler not only in
> driver thread but for drivers itself?


It's a trade off.

Either non-standard drivers prepend their first read with 20 bytes in Recv().
(~ two lines of code)

*OR*

You need to change all parts of the sever that expect an HTTP request
structure to be available. AND you need to account for the fact that
sometimes it gets created in the normal fashion, but other times it
gets created later, or not at all.


You've tried to ways to do this:


1) Exposing a new Ns_DriverSetRequest routine.

Here's what it looked like in nssyslogd:

http://naviserver.cvs.sourceforge.net/viewvc/naviserver/modules/nssyslogd/nssyslogd.c?revision=1.18&view=markup

NS_EXPORT int
Ns_ModuleInit(char *server, char *module)
{
...
Ns_RegisterRequest(server, "SYSLOG",  "/", SyslogRequestProc,
NULL, srvPtr, 0);
...
}

static NS_DRIVER_ACCEPT_STATUS
Accept(Ns_Sock *sock, SOCKET listensock, struct sockaddr *sockaddrPtr,
int *socklenPtr)
{
sock->sock = listensock;
Ns_DriverSetRequest(sock, "SYSLOG / HTTP/1.0");
return NS_DRIVER_ACCEPT_DATA;
}


How is this functionally different to what I proposed (example in Recv above)?


2) Doing away with the need for a Ns_Request all together.

Which now looks like this:

http://naviserver.cvs.sourceforge.net/viewvc/naviserver/modules/nssyslogd/nssyslogd.c?revision=1.19&view=markup

NS_EXPORT int
Ns_ModuleInit(char *server, char *module)
{
...
init.requestProc = Request;
...
init.opts = NS_DRIVER_ASYNC | NS_DRIVER_NOPARSE;
...
}

static int
Request(void *arg, Ns_Conn *conn)
{
Ns_DString *dsPtr = Ns_ConnSockContent(conn);
SyslogRequest *req = SyslogRequestCreate(server, sockPtr->sock,
dsPtr->string, dsPtr->length, &sa);
SyslogRequestProcess(req);
...
}


The strategy here seems to be to completely ignore the standard
request structure and do your own thing. There's nothing wrong with
this in the abstract -- you're not actually using any of the HTTP
stuff. However, the rest of the server fully expects the HTTP request
to be present and filled in, and this is why you've had to touch
dozens of files in dozens of places fixing up all code that might trip
over a null request field. (And the public API has changed...)


As far as I can see, neither method 1 or 2 achieves anything than
passing "METHOD / HTTP/1.0\r\n\r\n" does, using considerably less
code.

For example, In the snippet above, you can see the newly added
Ns_ConnSockContent which returns a pointer to the read buffer (which
is otherwise private). Ordinarily the buffer would contain the HTTP
request line, any headers, then any body. You can get at the body with
the existing Ns_ConnContent. So if you just return "SYSLOG /
HTTP/1.0\r\n\r\n" and then your bytes in Recv(), the request would be
constructed and then you could parse the protocol beginning in the
body content.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] modules/nsssl nsssl.c,1.6,1.7

2008-10-22 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 9:03 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> I tried to use Ns_SockSendBufs() but it sends data directly to socket
> where i need to send via driver's send proc.


Just pass your Send() proc directly, and delete SendBufs():

 static ssize_t
 SendFile(Ns_Sock *sock, Ns_FileVec *bufs, int nbufs, Ns_Time
*timeoutPtr, int flags)
 {
-return Ns_SockSendFileBufsIndirect(sock->sock, bufs, nbufs,
timeoutPtr, flags, SendBufs);
+return Ns_SockSendFileBufsIndirect(sock->sock, bufs, nbufs,
timeoutPtr, flags, Send);
 }


> Why connPtr->nContentSent is not updated, all send called with conn
> parameters should do this


Yes, but Ns_ConnSend() is higher up the stack, so when sending data it
looks something like this:

return.c: Ns_ConnReturnData
connio.c: Ns_ConnWriteData
connio.c: Ns_ConnWriteVData
connio.c: Ns_ConnSend
driver.c: NsDriverSend
nsssl/nsssl.c: Send


By the time your Send() is called we've already passed through
Ns_ConnSend(). nContentSent will be updated as the stack unwinds.

If you call Ns_ConnSend() from within Send(), that's a loop...

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] modules/nsssl nsssl.c,1.6,1.7

2008-10-22 Thread Stephen Deasey
> Index: nsssl.c
> ===
> RCS file: /cvsroot/naviserver/modules/nsssl/nsssl.c,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -C2 -d -r1.6 -r1.7
> *** nsssl.c 22 Oct 2008 02:14:24 -  1.6
> --- nsssl.c 22 Oct 2008 03:23:06 -  1.7
> ***
> --- 432,447 
>   */
>
> ! static int
> ! SendBufs(SOCKET sock, struct iovec *bufs, int nbufs, Ns_Time *timeoutPtr, 
> int flags)
>  {
> ! Ns_Conn *conn = Ns_GetConn();
> !
> ! return Ns_ConnSend(conn, bufs, nbufs);
> ! }
> !


This should be Ns_SockSendBufs(), otherwise connPtr->nContentSent will
be double counted and the driver thread may block.

Although in this case it should actually be Send(), which is your SSL
specific implementation of Ns_SockSendBufs(). The way it is now static
files may be sent in the clear :-/


(Basically, you implement the SendFile() callback by calling
Ns_SockSendFileIndirect(), which is the default library implementation
which scrapes the bytes off disk, and pass it Send(), which is your
implementation of writing to the network.  nssock is maybe a little
confusing in that it doesn't actually do anything but call the default
implementations, because it doesn't have to...)

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] modules/nsssl nsssl.c,1.6,1.7

2008-10-22 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 4:23 AM, Vlad Seryakov
<[EMAIL PROTECTED]> wrote:
> Update of /cvsroot/naviserver/modules/nsssl
> In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22913/modules/nsssl
>
> Modified Files:
>nsssl.c
> Log Message:
> new accept status, SSL driver works now
>
>
> Index: nsssl.c
> ===
> *** 286,298 
>
>  if (sslPtr == NULL) {
> ! sslPtr = SSL_new(drvPtr->ctx);
>  if (sslPtr == NULL) {
>  Ns_Log(Error, "%d: SSL session init error for %s: [%s]", 
> sock->sock, ns_inet_ntoa(sock->sa.sin_addr), strerror(errno));
>  return NS_DRIVER_ACCEPT_ERROR;
>  }
>  sock->arg = sslPtr;
> ! SSL_set_fd(sslPtr, sock->sock);
> ! SSL_set_accept_state(sslPtr);
> !
>  }
>  return NS_DRIVER_ACCEPT_DATA;
> --- 293,306 
>
>  if (sslPtr == NULL) {
> ! sslPtr = ns_calloc(1, sizeof(SSLContext));
> ! sslPtr->ssl = SSL_new(drvPtr->ctx);
>  if (sslPtr == NULL) {
>  Ns_Log(Error, "%d: SSL session init error for %s: [%s]", 
> sock->sock, ns_inet_ntoa(sock->sa.sin_addr), strerror(errno));
> + ns_free(sslPtr);
>  return NS_DRIVER_ACCEPT_ERROR;
>  }
>  sock->arg = sslPtr;
> ! SSL_set_fd(sslPtr->ssl, sock->sock);
> ! SSL_set_accept_state(sslPtr->ssl);
>  }
>  return NS_DRIVER_ACCEPT_DATA;
> ***


The check for (sslPtr == NULL) happens after it's already been used.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver/nsd driver.c,1.119,1.120

2008-10-22 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 4:23 AM, Vlad Seryakov
<[EMAIL PROTECTED]> wrote:
> Update of /cvsroot/naviserver/naviserver/nsd
> In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22913/nsd
>
> Modified Files:
>driver.c
> Log Message:
> new accept status, SSL driver works now
>
>
> Index: driver.c
> ===
> RCS file: /cvsroot/naviserver/naviserver/nsd/driver.c,v
> retrieving revision 1.119
> retrieving revision 1.120
> diff -C2 -d -r1.119 -r1.120
> *** driver.c20 Oct 2008 00:06:54 -  1.119
> --- driver.c22 Oct 2008 03:23:06 -  1.120
> ***
> *** 787,791 
>   * Results:
>   *  _ACCEPT:   a socket was accepted, poll for data
> !  *  _ACCEPT_DATA:  a socket was accepted, data present
>   *  _ACCEPT_ERROR: no socket was accepted
>   *
> --- 787,793 
>   * Results:
>   *  _ACCEPT:   a socket was accepted, poll for data
> !  *  _ACCEPT_DATA:  a socket was accepted, data present, read immediately
> !  * if in async mode, defer reading to connection thread
> !  *  _ACCEPT_QUEUE: a socket was accepted, queue immediately
>   *  _ACCEPT_ERROR: no socket was accepted
>   *
> ***
> *** 1523,1534 
>
>  } else {
>  drvPtr->queuesize++;
>
> - /*
> -  * If there is already data present then read it without
> -  * polling if we're in async mode.
> -  */
> -
>  if (status == NS_DRIVER_ACCEPT_DATA) {
>  if (drvPtr->opts & NS_DRIVER_ASYNC) {
>  status = SockRead(sockPtr, 0);
> --- 1525,1538 
>
>  } else {
> + status = SOCK_MORE;
>  drvPtr->queuesize++;
>
>  if (status == NS_DRIVER_ACCEPT_DATA) {
> +
> + /*
> +  * If there is already data present then read it without
> +  * polling if we're in async mode.
> +  */
> +
>  if (drvPtr->opts & NS_DRIVER_ASYNC) {
>  status = SockRead(sockPtr, 0);
> ***
> *** 1541,1553 
>
>  /*
> !  *  We need to call this to make sure socket has request 
> structure allocated,
> !  *  otherwise NsGetRequest will call SockRead which is not 
> what this driver wants
>   */
>
> - SockPrepare(sockPtr);
>  status = SOCK_READY;
>  }
> ! } else {
> ! status = SOCK_MORE;
>  }
>  }
> --- 1545,1564 
>
>  /*
> !  * Queue this socket without reading, NsGetRequest in
> !  * the connection thread will perform actual reading of the 
> request
>   */
>
>  status = SOCK_READY;
>  }
> ! } else
> ! if (status == NS_DRIVER_ACCEPT_QUEUE) {
> !
> ! /*
> !  *  We need to call SockPrepare to make sure socket has request 
> structure allocated,
> !  *  otherwise NsGetRequest will call SockRead which is not what 
> this driver wants
> !  */
> !
> ! SockPrepare(sockPtr);
> ! status = SOCK_READY;
>  }
>  }


Why the new accept status: NS_DRIVER_ACCEPT_QUEUE ?

The idea we talked about with the driver callbacks was that a
non-standard driver could fake-up a request in it's read callback. So,
whereas at the mo you have something like this:

modules/nsudp/nsudp.c:

static NS_DRIVER_ACCEPT_STATUS
Accept(Ns_Sock *sock, SOCKET listensock, struct sockaddr *sockaddrPtr,
int *socklenPtr)
{
sock->sock = listensock;
return NS_DRIVER_ACCEPT_DATA;
}

static ssize_t
Recv(Ns_Sock *sock, struct iovec *bufs, int nbufs, Ns_Time
*timeoutPtr, int flags)
{
 socklen_t size = sizeof(struct sockaddr_in);

 return recvfrom(sock->sock, bufs->iov_base, bufs->iov_len, 0,
(struct sockaddr*)&sock->sa, &size);
}


You would instead do something like this:


static ssize_t
Recv(Ns_Sock *sock, struct iovec *bufs, int nbufs, Ns_Time
*timeoutPtr, int flags)
{
static const char request[] = "GET /whateva HTTP/1.0\r\n\r\n";
size_t requestLen = sizeof(request);
socklen_t sockLen = sizeof(struct sockaddr_in);

memcpy(bufs->iov_base, request, requestLen);

return recvfrom(sock->sock,
bufs->iov_base + requestLen,
bufs->iov_len - requestLen,
0, (struct sockaddr*) &sock->sa, &size);
}

(checking for buffer lengths skipped here)


The advantage of doing it this way is that everything is much simpler
from the driver threads point of view. It doesn't need to know
anything special about non-standard protocols, and there isn't
anything in the driver callback api that isn't also useful to the HTTP
server.


Also, this can't work:

nsd/driver.c:1515

status = DriverAccept(sockPtr);

if (status == NS_DRIVER_ACCEPT_ERROR) {
status = SOCK_ERROR;
...

} else {
status 

Re: [naviserver-devel] naviserver ChangeLog,1.820,1.821

2008-10-22 Thread Stephen Deasey
On Wed, Oct 22, 2008 at 3:14 AM, Vlad Seryakov
<[EMAIL PROTECTED]> wrote:
> Update of /cvsroot/naviserver/naviserver
> In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17830
>
> Modified Files:
>ChangeLog
> Log Message:
> nsssl module ported, sock context and driver context exposed
>
>
> Index: ChangeLog
> ===
> RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v
> retrieving revision 1.820
> retrieving revision 1.821
> diff -C2 -d -r1.820 -r1.821
> *** ChangeLog   21 Oct 2008 21:46:36 -  1.820
> --- ChangeLog   22 Oct 2008 02:14:23 -  1.821
> ***
> *** 13,16 
> --- 13,24 
>  modules/nstftpd: ported to new driver API
>
> + modules/nsssl: Ported to new API
> +
> + nsd/conn.c: Added new Ns_ConnSockContext function which returns 
> sock->arg,
> + socket-wide context
> +
> + Ns_ConnDriverContext will now return connPtr->drvPtr->arg, this is 
> driver-wide
> + context.
> +


These structure members are already public, so Ns_ConnSockContext()
and Ns_ConnDriverContext() are not needed:

include/ns.h:

typedef struct Ns_Sock {
Ns_Driver  *driver;
SOCKET  sock;   /* Connection socket */
struct sockaddr_in  sa; /* Actual peer address */
void   *arg;/* Driver context. */
} Ns_Sock;

typedef struct Ns_Driver {
void*arg;   /* Driver callback data. */
   ...

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver/include nsthread.h,1.42,1.43

2008-10-05 Thread Stephen Deasey
I think we can just remove the O_LARGEFILE usage from log.c (only
place it's used).

_FILE_OFFSET_BITS handles this now.


On Sun, Oct 5, 2008 at 6:03 PM, Vlad Seryakov
<[EMAIL PROTECTED]> wrote:
> Update of /cvsroot/naviserver/naviserver/include
> In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21771/include
>
> Modified Files:
>nsthread.h
> Log Message:
> OS X does not have O_LARGEFILE
>
>
> Index: nsthread.h
> ===
> RCS file: /cvsroot/naviserver/naviserver/include/nsthread.h,v
> retrieving revision 1.42
> retrieving revision 1.43
> diff -C2 -d -r1.42 -r1.43
> *** nsthread.h  2 Oct 2008 01:36:18 -   1.42
> --- nsthread.h  5 Oct 2008 17:03:49 -   1.43
> ***
> *** 246,249 
> --- 246,253 
>  #endif
>
> + #ifdef __APPLE__
> + #define O_LARGEFILE 0
> + #endif
> +
>  #define O_TEXT  0
>  #define O_BINARY0
>
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> naviserver-commits mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/naviserver-commits
>

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver ChangeLog,1.787,1.788

2008-09-11 Thread Stephen Deasey
On Thu, Sep 11, 2008 at 10:53 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> will do, it may take a while
>

no problem

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] naviserver ChangeLog,1.787,1.788

2008-08-28 Thread Stephen Deasey
On Fri, Aug 29, 2008 at 2:12 AM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
>>> +* tests/http_byteranges.test: Add a couple of tests for ranges on
>>> +larger files to exercise the file descriptor path rather than the
>>> +in memory mmap or cache path. Unfortunately, this actually
>>> +triggers the writer thread and this has no support of ranges,
>>> +which I guess is where it's actually most needed. TODO...
>>> +
>>
>> I really like last changes, at the same time i need writer support
>> because my tests showed that serving big files with conn threads are
>> waste of resources.
>> At the same time, being able to support range in the writer make sense.
>>
>> And sent email without finishing the thought :-))
>
> Maybe parsing for range should done early enough and saved in the
> request, so whoever then will be sending data will use it.
>
> Just a thought from east coast :-))


I was thinking of adding support for sendfile().

It's different on every platform, so having looked at a few, I was
going to make our interface follow the Solaris senfilev() model which
basically allows an arbitrary number of interleaved memory and file
ranges.  It's an almost exact fit for our byterange code  :-)

Here's the man page:

http://docs.sun.com/app/docs/doc/816-5172/sendfilev-3ext?a=view

So we'd end up with an array of those sendfilev_t-like structures
describing the data to send. Not sure if they should go in the
conn/request, or...   But maybe it should be a public interface,
unlike the Range struct which is kind of a private thing atm.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Bug in fastpath cache causes info leak

2008-08-28 Thread Stephen Deasey
On Thu, Aug 28, 2008 at 9:52 PM, Vasiljevic Zoran <[EMAIL PROTECTED]> wrote:
>
> On 21.08.2008, at 21:06, Stephen Deasey wrote:
>
>> You used to have to manually edit the makefile to disable zippy. Is
>> this still the case?
>>
>> Perhaps the Tcl default should be to use the system allocator even on
>> threaded builds, and to provide a configure switch to enable zippy.
>> Zoran, you have Tcl cvs access right?
>
> Yes. I just discussed this with Vlad.
> Here is the consensus:
>
> There is Tcl single-threaded allocator and zippy allocator.
>
> If you turn on Tcl allocator it should use
>  single-threaded allocator for non-thread builds
>  zippy allocator for thread builds
>
> If you turn off Tcl allocator it should use
>  system-level malloc regardless of the thread/nonthread builds
>
> This is most "logical" setup. So, either you have custom Tcl
> memory allocator or not. If you dont, then system malloc is used.
> If you do, then it depends on the threaded build.
>
> To aid this, there is (confugure-wise unused) USE_TCLALLOC define.
> Control which (simple one-lock Tcl allocator or AOL's zippy allocator)
> is selected, is done over USE_THREAD_ALLOC.
>
> By allowing the USE_TCLALLOC  to be confugured "from the outside"
> one can decide wether TCL allocator (singlethreaded or zippy)
> or system/OS malloc us used.
>
> The USE_THREAD_ALLOC is implicitly set (reset) when threaded build
> is configured (or not).
>
> This way we would have one "knob" (the USE_TCLALLOC) which we can
> toggle over --enable-tclalloc (default us true). By --disable-tclalloc
> we would default to system level alloc, thread build or not.
>
> This is the path of least resistence and would not change any defaults.
> I could go to the Tcl core list with this suggestion, yes.
>
> Vlad suggested to raise the queston of disabling the zippy even for
> thread builds, per default. I can only second that. But then again,
> we would change the default behaviour from as-is now and that is a
> chance to get some oposition which I do not have time to deal with.
>
> What do you think?


Sounds sensible. Configuration knob first, change defaults later, possibly.

To change the default is going to require proof that one way is better
than another anyway. There's a Tcl performance test suite somewhere,
right?  Some work for somebody...

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] Last build, cache test failure

2008-08-28 Thread Stephen Deasey
On Tue, Aug 26, 2008 at 11:36 PM, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> I spent a lot of time and still cannot resolve the problem with latest
> version ns_cache test failure.
>
> One problem i noticed with latest Tcl 8.5.4, in crashes nsd in thread
> test in 64bit and hangs forever in 32bit Linux.
>
> But ns_caches fails with tests using -expires and i rolled back the
> changed i made recently and it still fails. I cannot see why driver
> change would make it fail, but other sources are the same.
>
> Help please


When doing development, as opposed to building for install, you MUST
run autogen.sh with --prefix=/tmp/ns or some other path that is
unlikely to have a copy of the naviserver libraries.

Otherwise, you will drive yourself insane...  :-)

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


  1   2   3   4   5   6   7   >