Commit Graph

350 Commits

Author SHA1 Message Date
Stephen Halter 3eec43a0c3 Move static BitCount method to base class
- Updated comment to point to a specific commit in corefx
- This is more consistent with AppendValue since BitCount doesn't need
  to be generated
2015-10-09 17:27:33 -07:00
Stephen Halter a33a5d0f1b Merge branch 'benaadams/bitcount-fast' into dev 2015-10-09 17:17:03 -07:00
Louis DeJardin 78177e7082 Fixing rebase errors 2015-10-09 13:26:34 -07:00
Louis DeJardin 6ae0f5d505 PR feedback - code formatting 2015-10-09 13:19:10 -07:00
Louis DeJardin 29b0b124ee Moving non-changing methods into .cs partial 2015-10-09 13:19:09 -07:00
Ben Adams ccfeef6353 All features to have backing object 2015-10-09 13:18:32 -07:00
Ben Adams 8f41e47eca Remove bitfield for locally implemented interface items
Only generate type statics for cached features
2015-10-09 13:18:09 -07:00
Ben Adams 3c20053d9a Don used cached typeof for tests 2015-10-09 13:15:39 -07:00
Ben Adams 56893df7f9 Don't iterate overriden features twice 2015-10-09 13:11:48 -07:00
Louis DeJardin cbc3b4e6f5 PR Feedback
* Sorting namespaces
* Removing `as` casting for Frame's implemented interfaces
2015-10-09 13:10:27 -07:00
Louis DeJardin dc0eb679ae Updating unit tests for Frame IFeatureCollection update 2015-10-09 13:09:37 -07:00
Louis DeJardin 71fc2bf2e5 Rough implementation of feature collection optimization 2015-10-09 13:09:35 -07:00
Ben Adams 6b0fa776ca More comment clarity 2015-10-09 12:16:54 -07:00
Ben Adams 47973541b5 Remove redundant cast 2015-10-09 12:16:53 -07:00
Ben Adams e107c47913 Add comment explanation 2015-10-09 12:16:52 -07:00
Ben Adams 05702e81e6 more typeof caching 2015-10-09 12:16:50 -07:00
Ben Adams d48a27dd59 Use bitflag for override and cache typeof in statics 2015-10-09 12:16:49 -07:00
Louis DeJardin dcf591c832 Rough implementation of feature collection optimization 2015-10-09 12:16:48 -07:00
Stephen Halter 0c1b05ce2d Merge branch 'release' into dev 2015-10-08 16:40:13 -07:00
Ben Adams 6f506ba988 subsequent block has data - IsEnd is false
Resolves #249
2015-10-08 16:18:47 -07:00
Stephen Halter 24c0a8e142 Fix MemoryPoolIterator2.CopyTo's block traversal
- This fix prevents large request streams from being corrupted

#234
2015-10-08 16:16:41 -07:00
Ben Adams 9d251cdb54 subsequent block has data - IsEnd is false
Resolves #249
2015-10-08 18:13:22 -04:00
Chris R 0b36382448 Merge pull request #236 from benaadams/sanitize-loops
Sanitize loops
2015-10-08 10:05:17 -07:00
Ben Adams 0a297688b4 Use Jit recongised, standard loop construct
For bounds check elimination.
Convey intent more clearly; eliminate bounds checks
2015-10-08 12:31:21 -04:00
Ben Adams 4250d35347 PR feeback 2015-10-08 01:11:41 -04:00
Ben Adams 05418dd18a Use corefx implementation 2015-10-07 16:51:10 -04:00
Ben Adams 8bf2c814d6 Add BitCount LongExtensions 2015-10-07 12:23:20 -04:00
Chris R 1f50f4c2a8 #231 bind to IPv6Any, add functional tests. 2015-10-05 16:13:11 -07:00
Ryan Nowak f545f99dab Add attributes to fix the build 2015-10-05 11:22:30 -07:00
Stephen Halter 2f3a00625a Initial work to support HTTPS using SslStream
- Add extension method "UseKestrelHttps" to IApplicationBuilder
2015-10-05 03:15:18 -07:00
Pranav K 49451fb11e Renaming Microsoft.Framework.* -> Microsoft.Extensions.* 2015-10-03 15:44:45 -07:00
Stephen Halter 6d3e5d3bf2 Merge branch 'benaadams/fastpath-header-enumerator' into dev 2015-09-28 12:21:58 -07:00
moozzyk d2f282f54f Consuming Libuv from NuGet package
Fixes #50
2015-09-26 18:00:50 -07:00
Chris R e3f141fcde #227 Fix OverflowException in MemoryPool 2015-09-26 06:56:54 -07:00
Stephen Halter f0137b7b9e Bind to specific IP addresses if provided with any
This still only applies to IPv4.

#98
2015-09-25 16:26:01 -07:00
Ben Adams 1718b69f22 Fast path header enumerator
Use strongly typed enumerable as interface's allocates.
2015-09-26 00:16:42 +01:00
damianedwards a7b65efa75 CR feedback 2015-09-25 14:59:47 -07:00
damianedwards 3c2408db68 Fix tests after rebase 2015-09-25 14:59:47 -07:00
damianedwards 7c46b2bd3b Use a timer to generate the value for the Date header in responses:
- Doing it on each request is expensive
- The Timer is started when the first request comes in and fires every second
- Every request flips a bool so the Timer knows requests are coming in
- The Timer stops itself after a period of no requests coming in (10 seconds)
- #163
2015-09-25 14:59:47 -07:00
Louis DeJardin 5070b8073e Temporarily commenting out the Debug.Assert of block freeing
Unit tests using ad-hoc contexts aren't guaranteed to dispose pools.
That's kinda making unit tests fail, more or less, because Debug...
2015-09-25 14:17:09 -07:00
Louis DeJardin 318f3b7145 Changing Trace.Assert to Debug.Assert
* Also Debug.Assert for unreturned memory blocks
2015-09-25 13:01:54 -07:00
Louis DeJardin f740616573 disposedValue changed to _disposedValue
Boilerplate code didn't have _
2015-09-25 12:49:30 -07:00
Louis DeJardin c42dace9e6 consts looked like local vars 2015-09-25 12:49:30 -07:00
Louis DeJardin 0adbbd0217 Using the well-known-header field without checking set bit 2015-09-25 12:49:29 -07:00
Stephen Halter dc902f5fc4 Update SocketOutput to not call QueueUserWorkItem unnecessarily 2015-09-25 12:49:28 -07:00
Louis DeJardin 789d5b3595 Writes which are not immediate always return completed tasks
They must always be followed with Writes which are immediate, and
returning an incomplete task put them in a state where the callback
might not have been initiated.
2015-09-25 12:49:27 -07:00
Louis DeJardin 5e678fdbaa Adding volatile keyword to stopping boolean 2015-09-25 12:49:27 -07:00
Louis DeJardin 99fc7e4e50 Moving the Start/Stop logic into Frame.
Also formalizes the relationship between the function's Task and
how it relates to graceful shutdown. Specifically how it relates
to finishing the requests currently in progress.
2015-09-25 12:49:26 -07:00
Louis DeJardin f89a586b75 Removing boilerplate-generated #region 2015-09-25 12:49:25 -07:00
Louis DeJardin 37f7dfd01f Typo in comments 2015-09-25 12:49:25 -07:00
Louis DeJardin c424b8437c Renaming based on PR feedback 2015-09-25 12:49:24 -07:00
Louis DeJardin 844c791b16 Processing function should return Task 2015-09-25 12:49:23 -07:00
Louis DeJardin 091084cfe2 Refactoring MemoryPool class locations
Moving Iterator out into its own file rather than being a nested class
Moving pool classes into Infrastructure namespace instead of Http
2015-09-25 12:49:23 -07:00
Louis DeJardin 13defc5a32 Initialize Memory2 in ListenerContext
Better than initializing from multiple other classes
2015-09-25 12:49:22 -07:00
Louis DeJardin 5ba1b9fb3c Secondary listeners need to allocate their own memory pool 2015-09-25 12:49:21 -07:00
Louis DeJardin 6db3d9e645 Using specific exception types 2015-09-25 12:49:21 -07:00
Louis DeJardin 76b528e1d2 Adding comments to MemoryPool classes 2015-09-25 12:49:20 -07:00
Louis DeJardin ff0affe34d Removing _frameTask and fixing Task.Run argument 2015-09-25 12:49:19 -07:00
Louis DeJardin 30ec2cb0b1 Harden framing epilog
* Connection no longer needes Frame's processing Task
* Any exceptions from unusual processing is logged
2015-09-25 12:49:19 -07:00
Louis DeJardin 28250d9981 Providing Path to application 2015-09-25 12:49:18 -07:00
Louis DeJardin 04f6446a50 Updates for PR feedback 2015-09-25 12:49:18 -07:00
Louis DeJardin d3a87c4c14 Removing MessageBodyExchanger base class 2015-09-25 12:49:17 -07:00
Louis DeJardin 52dc37eae7 Fixing a header parsing bug
When request header data arrives with \r\n split across packets
2015-09-25 12:49:16 -07:00
Louis DeJardin e5a3bda3a2 Progress on flow control
* Dealing with race conditions
* Reworking iterator methods
* Shutdown and Close need to be passed throught the write-behind mechanism
2015-09-25 12:49:15 -07:00
Louis DeJardin 4193c92ba7 Fixing merge conflicts 2015-09-25 12:49:15 -07:00
Louis DeJardin 1f6aaebeda Changing flow control for incoming data
SocketInput is now awaitable
Input buffers are slab-allocated and pinned from large object heap
Request frame parsing is offloaded from libuv thread
2015-09-25 12:49:14 -07:00
Louis DeJardin 557f6d6993 Refactoring response control flow
- Bring through both sync and async execution paths
- Remove callback pattern from from and socketoutput write calls
2015-09-25 12:47:51 -07:00
Stephen Halter 1e39473047 uv_pipe_connect returns void
This fix prevents Libuv.pipe_connect from throwing when the stack
memory that was previously incorrectly interpreted as the int return
value happens to be negative.

When pipe_connect threw, an assertion failure would follow since the
pipe handle would be closed prematurely.

http://docs.libuv.org/en/v1.x/pipe.html#c.uv_pipe_connect

#205
2015-09-25 11:40:40 -07:00
Eilon Lipton c4bf10d6e9 Add third party notices for libuv
Fixes #218
2015-09-23 15:42:58 -07:00
Chris R 355bc01a15 Hosting#358 Move the default address into Hosting. 2015-09-22 11:56:46 -07:00
David Fowler 891b991a34 Use new packInclude feature to include native assets
- Now Kestrel won't break when people overwrite the build.cmd
2015-09-19 03:59:58 -07:00
Stephen Halter 47323a88e1 Surface errors from Listener.StartAsync better
If CreateListenSocket fails, surface the original error instead of throwing a
NullReferenceException from Listener.Dispose().

#185
2015-09-16 18:19:01 -07:00
Stephen Halter 2d01f2752b Catch and log uv_accept errors
- This is also what is done by node.js
- "tcp, pipe: don't assert on uv_accept() errors (Ben Noordhuis)"

0685707bc6
2015-09-16 18:18:58 -07:00
Stephen Halter f14af1f409 Don't swallow too many exceptions
- Swallowing too many exceptions can end up hiding issues in
  Kestrel itself. It's better to let the process die.
- If we want to handle certain exceptions we should be as
  specific as possible with our try/catch blocks.
2015-09-16 18:18:55 -07:00
Chris R 2e225b0db6 Hosting#331 Add IServerAddressesFeature. 2015-09-15 12:47:18 -07:00
Pranav K 78de14d248 Adding NeutralResourcesLanguageAttribute 2015-09-10 18:15:27 -07:00
Stephen Halter 958cc3eca3 Add missing arguments to LogDebug arguments in KestrelTrace 2015-09-10 12:40:16 -07:00
Stephen Halter 813127e7f6 Merge branch 'benaadams/negative-threads' into dev 2015-09-10 11:58:09 -07:00
Stephen Halter ec88e57f67 Remove commented code in KestrelTrace 2015-09-10 11:41:27 -07:00
Stephen Halter 1ebf98d40d Log message style changes
- Disabled some log messages for possibly being too verbose.
- Don't log ConnectionReadFin when there is an error.
2015-09-10 11:41:25 -07:00
Stephen Halter 0ef096b41c Increment connection id for logging 2015-09-10 11:41:22 -07:00
Ben Adams dda5774a8b Throw exception if ThreadCount negative 2015-09-10 08:03:42 +01:00
Ben Adams 887cf2c7be Negative thread count fix 2015-09-10 02:57:49 +01:00
Stephen Halter dc08062545 Merge branch 'drussilla/add-logging' into dev
Conflicts:
	src/Microsoft.AspNet.Server.Kestrel/Http/Connection.cs
	src/Microsoft.AspNet.Server.Kestrel/Http/ListenerSecondary.cs
2015-09-09 11:28:09 -07:00
Ivan Derevyanko ac77c11211 Make ConnectionCallback static again. 2015-09-09 02:13:49 +02:00
Ivan Derevyanko 2b2943d5b0 Restore static delegates 2015-09-09 01:27:44 +02:00
Stephen Halter 2041e4d08b Prevent pipes from being closed prematurely on OS X and Linux
This change fixes the in-process marshalling of TCP handles on Mac and Linux
that is used to support having multiple threads accepting connections from
multiple loops.

On these two platforms, the ReadStart callback somtimes gets called with a
status and pipe_pending_count equal to zero. Now when the status is zero
just exit the callback without closing the pipe.

This change more closely follows the example at
https://nikhilm.github.io/uvbook/processes.html#sending-file-descriptors-over-pipes
2015-09-08 16:21:45 -07:00
Ivan Derevyanko a93a66fe7c Replace Trace.WriteLine with ITraceLogger 2015-09-09 00:26:26 +02:00
Ivan Derevyanko 6d47227975 KestrelTrace refactored and added to the ServiceContext. Close aspnet/KestrelHttpServer#141 2015-09-05 18:17:17 +02:00
Kai Ruhnau 5ee80e0155 Fix bug #191 introduced by b25d2d9 2015-09-05 12:29:00 +02:00
Stephen Halter f10c989d90 Add ServiceContext to make it easier to flow new services through ctors 2015-09-04 15:04:25 -07:00
Stephen Halter 1584d70e1f Clean up if an exception is thrown in the middle of ServerFactory.Start 2015-09-03 15:26:30 -07:00
Louis DeJardin c50aec1729 Adding comments to meaningless field names 2015-09-02 21:14:18 -07:00
Louis DeJardin dffd977c3f Fixing field names 2015-09-02 20:50:21 -07:00
Louis DeJardin 5c7007a4e9 Fixing member field name 2015-09-02 20:37:11 -07:00
Louis DeJardin 0859d82d6b Adding private keyword to private enums 2015-09-02 20:33:51 -07:00
Louis DeJardin 3bbb77f9d0 Alphabetizing using statements 2015-09-02 20:31:11 -07:00
Louis DeJardin b25d2d9772 Continued updates for #184
* Reordering members
- Fields
- Constructors
- Properties
- EverythingElse
- NestedTypes

* Removing commented code
2015-09-02 20:08:54 -07:00
Louis DeJardin 2467cf2ade Nested types must be last 2015-09-02 00:07:58 -07:00
Louis DeJardin 46604d68b3 Initial commit for style cleanup #184
* adding private keyword to fields
* one type per file
2015-09-01 22:25:51 -07:00
Chris R c2192d7bd1 Change IServerInformation to IFeatureCollection. 2015-09-01 15:27:57 -07:00
Stephen Halter d0bd2b3dd0 Configure unix pipes via the hostname instead of the scheme. 2015-08-31 10:46:48 -07:00
Stephen Halter a919ea8d0a Remove unnecessary listener interfaces 2015-08-31 10:46:46 -07:00
Stephen Halter a9b8cfa582 Remove unnecessary use of generics in listeners 2015-08-31 10:46:40 -07:00
Chris R 803ec38073 React to string[] -> StringValues changes. 2015-08-28 12:59:00 -07:00
Stephen Halter 40ca61b640 Merge branch 'release' into dev 2015-08-26 16:32:19 -07:00
Stephen Halter 2642c84bf9 Don't automatically set Content-Length: 0 in some circumstances
- When in response to a HEAD Request
- For 101, 204, 205 and 304 responses
- For non keep-alive connections
2015-08-26 16:16:35 -07:00
Stephen Halter 69759231ff Set Content-Length: 0 when an AppFunc completes without a write
- Previously an incomplete chunked response would be written instead.
- Add test to verify Content-Length: 0 is set automatically.
- Add test to verify HTTP/1.0 keep-alive isn't used if no Content-Length
  is set for the response.
- Add tests to verify errors are handled properly after chunked writes.

#173
2015-08-25 23:17:41 -07:00
Stephen Halter ca0a42a01e Merge branch 'Daniel15/unix-sockets' into dev 2015-08-24 12:53:31 -07:00
Pranav K 7cdfdddaa0 Unpinnng Dnx.Runtime.Abstractions package version 2015-08-18 21:34:43 -07:00
Daniel Lo Nigro 9ade227abb Implement support for UNIX sockets.
The common use-case for Kestrel in production will be behind a reverse proxy such as Nginx. In cases where the reverse proxy is located on the same machine as the application, connecting via a UNIX socket is more efficient than a TCP socket, as it avoids going through the network layer. Accessing 127.0.0.1 through TCP still needs to initiate a TCP connection and perform handshaking, checksumming, etc, all of which is avoided by using UNIX sockets.

 - Moved TCP-specific stuff from Listener into new TcpListener class (same with ListenerPrimary and ListenerSecondary)
 - Made Listener abstract
 - Created new PipeListener. Note that while the use case is for UNIX sockets, this is called "Pipe" in uv, so I've called this "PipeListener" so the terminology is consistant
 - Uses "unix" URL scheme to determine whether to use socket. "http://127.0.0.1:5000" is for listening via TCP while "unix:///var/run/kestrel-test.sock" is for listening via UNIX socket

#156
2015-08-15 15:50:34 -07:00
Stephen Halter 753d64660d Ignore zero length writes when automatically chunking responses
- Zero length writes would previously be interpreted as the end of response
- Optimize writing the chunked response suffix
- Add tests for automatic response chunking
2015-08-14 15:59:47 -07:00
Stephen Halter 3fb33119ee Initial non-optimized support for automatically chunking responses 2015-08-14 15:59:39 -07:00
Stephen Halter 32c4f314b6 Lock around Connection.End to make it thread-safe 2015-08-14 12:17:06 -07:00
Stephen Halter 4f0480a4d0 Gracefully handle exceptions thrown from OnStarting callbacks
- If OnStarting is being called after the app func has completed, return a 500.
- If Onstarting is being called due to a call to write, throw from write.
2015-08-14 12:05:43 -07:00
Stephen Halter 6a01043e1a Fix ListenerSecondary so it reliably accepts new connections on Windows
Calling uv_read_start on a named pipe with a larger than necessary buffer
would cause pieces of the next uv_ipc_frame_uv_stream struct to be read into
the uv_read_start buffer when a lot of tcp handles were passed quickly over
the pipe.

This prevented the struct from properly being queued for the next call to
uv_accept to consume. The empty queue caused the call to uv_accept in
ListenerSecondary to fail and return WSAEWOULDBLOCK leaving the connection
in a zombie state.
2015-08-14 11:57:21 -07:00
Stephen Halter c0cc511b5b Prevent access to closed socket in in Connection.End 2015-08-14 11:49:45 -07:00
Stephen Halter b162202519 Properly close keep alive connections 2015-08-14 11:49:43 -07:00
Chris R 43ebf710ab Fix regression in reading config 2015-08-14 09:33:02 -07:00
Kirthi Krishnamraju c7535f127c fix build break due to aspnet\configuration #246 2015-08-13 22:42:48 -07:00
Stephen Halter 097fb35ddf Fix startup when you reference the assembly directly instead of Hosting
- I missed this change in Program.cs when doing the initial package merging
2015-08-12 15:14:01 -07:00
Stephen Halter d97b02696f Merge Kestrel into Microsoft.AspNet.Server.Kestrel 2015-08-11 14:56:20 -07:00
Stephen Halter 0ac3c3dad6 More ConfigureAwait(false) 2015-08-11 12:46:08 -07:00
Stephen Halter 688ad9bee7 Merge branch 'benaadams/configure-awaits' into dev 2015-08-11 12:34:53 -07:00
Stephen Halter 5dfca955b3 Move GeneratedCode project so no NuGet package gets created 2015-08-05 12:22:59 -07:00
Stephen Halter 7dd256f26e Add a "dnu restore" prepare step before generating code
- This ensures the generated code project's project.lock.json is created
2015-08-05 11:54:17 -07:00
Stephen Halter 51693304c1 Update dependencies after rename to Microsoft.Dnx.Compilation.CSharp 2015-08-05 11:07:13 -07:00
Troy Dai b8f930bb4c Update CoreCLR versions 2015-08-04 10:15:28 -07:00
Stephen Halter e5144e3139 Include Server and Date in the initial response header dictionary 2015-08-03 16:20:34 -07:00
Stephen Halter 978dd39924 Update the prepare script used to generate code
- The syntax to run dnx with a modified appbase has recently changed
2015-08-03 16:20:32 -07:00
Stephen Halter 7446fe4cc7 Update SocketOutputTests to account for the "immediate" Write param 2015-08-03 16:20:30 -07:00
Louis DeJardin 6ff894bb19 Using masked byte sequences to recognize well-known header names 2015-08-03 16:20:28 -07:00
Louis DeJardin b999b47218 String concatination showed up in profiler 2015-08-03 16:20:26 -07:00
Louis DeJardin f6dc72544c Response headers don't need to be queued before subsequent write 2015-08-03 16:20:24 -07:00
Louis DeJardin c0728edda7 Linq .Any() was causing enumeration 2015-08-03 16:20:22 -07:00
Louis DeJardin f9cf9f1936 Improvements to appending request header 2015-08-03 16:20:20 -07:00
Louis DeJardin 96b03ee212 Perf - enumerate with struct
Conflicts:
	src/Microsoft.AspNet.Server.Kestrel/project.json
2015-08-03 16:20:18 -07:00
Louis DeJardin ad089be477 Removing "I like pie" diagnostics 2015-08-03 16:20:16 -07:00
Louis DeJardin 963f086eb0 Prototypeing a fast header dictionary
Conflicts:
	src/Microsoft.AspNet.Server.Kestrel/project.json
2015-08-03 16:20:14 -07:00
Chris R 83b2c95385 React to IFeatureCollection changes. 2015-08-03 15:13:58 -07:00
anurse 07304640ed react to DNX renames 2015-07-31 11:54:52 -07:00
Stephen Halter 4a9515d2e0 Gracefully handle uncaught exceptions in user code when possible 2015-07-30 16:01:33 -07:00
Troy Dai 07de3cafd1 Clean build warnings 2015-07-30 12:14:13 -07:00
Victor Hurdugaci 343d698286 React to DNX renames 2015-07-29 01:04:59 -07:00
Stephen Halter 47d7f73bdc Fix SocketOutput so that it can now complete large writes
- Complete in this context means that the callback gets invoked.
- Previously, calls to write would never complete if the buffer contained
  more than 64 KB (_maxBytesPreCompleted).
- This is tested by SocketOutputTests.CanWrite1MB.
2015-07-28 16:57:24 -07:00
Stephen Halter cce9d8f09c Make SocketOutput more testable
- Added a MockLibUv class
- Create a SocketOutputTests class
2015-07-28 16:57:22 -07:00
Stephen Halter c345849707 Don't use QueueUserWorkItem to trigger write callbacks immediately
- In this case we are off the event loop, so we can invoke the callback directly.
- Increase _maxBytesBufferedBeforeThrottling
2015-07-28 16:57:21 -07:00
Stephen Halter 74fa82bca7 Complete WriteAsync Tasks early when there are less than 64KB buffered 2015-07-28 16:57:19 -07:00
Stephen Halter d723f9da21 Reduce calls to uv_write by calling it with multiple buffers when possible 2015-07-28 16:57:16 -07:00
Louis DeJardin 5e6e5fec01 Adding an IKestralServerInformation.ThreadCount property
Will default to 1 until multi-loop stability is ensured
2015-07-27 11:40:39 -07:00