Addition of crypto.h and crypto.cpp to mordor project.

Change-Id: Ib00b0b493a75933e147e49e6e72baf437d72d7fe
Reviewed-on: https://gerrit.dechocorp.com/24024
Reviewed-by: David Brown <davidb@mozy.com>
fix ThroughputStatistic typo

* from ThroughputStatistic::update() function, it can be concluded that
  the time statistic should be defined as AverageMinMaxStatistic<U>

Change-Id: Ib36cf82c1bc9992eec292b29e662362364e92db7
Signed-off-by: Kevin Cai <kevinc@mozy.com>
Reviewed-on: https://gerrit.dechocorp.com/24175
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
kalyspo #43532: avoid detect invalid proxy over and over again

Originally we added some code to avoid auto proxy detection but only fix
some of call stacks of func autoDetectProxy(). But there are other paths
which detect invalid proxy again even it fails earlier.

Now I put more fix within func autoDetetProxy() so that if one proxy is invalid,
we don't detect it again unless resetDetectionResultCache() is called (usually
by network connection detection thread, or nlathread).

I change the resetDetectionResultCache() to static func so it's easier to reset
invalidProxy list.

Patch Set 3:
update patch based on Andrew's comment.

Signed-off-by: Henry CHEN <henryc@mozy.com>
Change-Id: Ia18e489c5b5141e40f9dca03fd5a1c7fd0b22b8a
Reviewed-on: https://gerrit.dechocorp.com/23718
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
Reviewed-by: Russ Simons <russs@mozy.com>
Support for XCode 4.2

Change-Id: Ib941abe985c9e76aef1c0ab659ca37edf017bfa5
Reviewed-on: https://gerrit.dechocorp.com/24535
Reviewed-by: Lance Helsten <lanceh@mozy.com>
Support persistent connection via http 1.0 proxy

Needed for pipelining of requests.  Was observed on the
Vmware proxy by Rodi Reich.

refs https://labs.dechocorp.com/issues/878

Change-Id: I7d92303d010f68d3833439acc36bd519f2aa9409
Reviewed-on: https://gerrit.dechocorp.com/24644
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
fixes #45138 - Support OAuth2.0 in mordor

Added a request broker for OAuth2.0.

Change-Id: I726d83f90286c8048ad956c60ccdfc43e239ecb5
Reviewed-on: https://gerrit.dechocorp.com/25136
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Russ Simons <russs@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
Reviewed-by: Henry Chen <henryc@mozy.com>
Add oauth2.h/cpp to mordor.vcproj/vcxproj.

Change-Id: I912dfd0d2ef6c59d0a385da6cf57e63ac0cdd7e1
Reviewed-on: https://gerrit.dechocorp.com/25232
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Henry Chen <henryc@mozy.com>
fix for ragel failure to resolve "../uri.rl"

seems like ragel on windows will only _sometimes_ try to resolve
include paths relative to the source file being compiled.  help
it out a bit in this specific case by explicitly marking
mordor/http as an include directory, so it will attempt
mordor/http/../uri.rl and find the include there.

Change-Id: I5acae003ccacd52a1575bcf14e901d5d04357923
Reviewed-on: https://gerrit.dechocorp.com/25258
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
allow custom logging of HTTP::Request and Response

instead of merely filtering, applications can perform their
own logging of Requests and Responses - or choose whether
to log based on URI, etc.

Change-Id: I8cbf61df071a12b5ab35a601432fdad66c349fab
Reviewed-on: https://gerrit.dechocorp.com/25578
Reviewed-by: Jenkins <hudsonbuild@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
Fix BufferedStream r/w thread-safe for seekless parent stream

* BufferedStream removes read-write thread-safe ability even the parent
  stream is read-write thread-safe, this change partially fixes the
  issue by make the r/w thread-safe when parent stream is seekless.
* 3 new unit tests is added to exposes the problem, (disabled one)

Change-Id: I38481e7f784027a58b3196b5150f5ff323d980e3
Signed-off-by: Kevin Cai <kcai@vmware.com>
Reviewed-on: https://gerrit.dechocorp.com/26121
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
refs #42355, pass size parameter while responding size-able stream

* If source stream supports size(), pass the size to transferStream when
  tranferring to respondStream. In this way if something wrong happens
  in source stream, tranferStream() will detect the stream is half
  tranferred. Otherwise, tranferStream() won't know the error and
  targetStream (NotifyStream) close will trigger assertion failure in
  ServerRequest::responseDone()

Change-Id: Ic9e2783c80d6af9742b228abf2b9b9f8d845f962
Signed-off-by: Kevin Cai <kcai@vmware.com>
Reviewed-on: https://gerrit.dechocorp.com/26167
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
Track maximum fiber count as mordor statistic

Too many fibers can result in crash, so track the
maximum number fiber objects created at a time

refs - https://labs.dechocorp.com/issues/839

Change-Id: I51e82168608436d9f0cdd086ae3589d75688b9bc
Reviewed-on: https://gerrit.dechocorp.com/26196
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
see #44076: auto create TempDir if it doesn't exist

When TempDir doesn't exist, GetTempFileName just fails. In this case, we
try auto-create TempDir and try again. If it still fails, raise MORDOR exception.

Patch Set 4:
change to use wstring::c_str() per Andrew's suggestion.

Signed-off-by: Henry CHEN <henryc@mozy.com>
Change-Id: Iad889ed93055d2734c519e5c0be8dd6b3a8489ee
Reviewed-on: https://gerrit.dechocorp.com/26168
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
Reviewed-by: Russ Simons <russs@mozy.com>
make Scheduler batch running exception-safe

Problem:
There are two problems in Scheduler::run() regarding to exception
throwed in batch Fiber:
1. When the exception throws, m_activeThreadCount is not decreased. This
  will cause the Scheduler stop() never exits, it handing in idle()
  waiting for the dead non-exist activeThread due to incorrect
  m_activeThreadCount
2. When batchSize > 1, as the exception throws, those fibers left in
  batch are not returned to m_fibers, which means these fibers are
  LOST. Scheduler should put the un-executed fibers back to m_fibers for
  re-scheduling.

Change-Id: I8628d480e4bd768f89fbd586b0941eca48ab36a1
Signed-off-by: Kevin Cai <kcai@vmware.com>
Reviewed-on: https://gerrit.dechocorp.com/26344
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
fixes the issue that IOManager hold expired Timers' resource too long

* While processTimer() in IOManager, the expired Timers' functors are
  saved in 'expired' vector, these functors will not be destructed
  until the expired variable is reset or cleared. This will make
  timer Client wait longer than expected even the timer is excuted,
  but the resource is not released. In case there are shared_ptr
  binding in functors, the object will be lived longer than expected.
* Fix the problem by clear the expired variable once the functors are
  scheduled into Scheduler.

Change-Id: I5c42e4edccf48510da6985854d3c119376b3d4fe
Signed-off-by: Kevin Cai <kcai@vmware.com>
Reviewed-on: https://gerrit.dechocorp.com/26348
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
Add two public methods for Scheduler

Add methods threads() and rootThreadId() for Scheduler to expose threads
info to outside world.

Signed-off-by: Xiangdong Lin <xiangdongl@mozy.com>
Change-Id: Ifc51a132433c0c120ee45d7b16bfa0ac6592a08a
Reviewed-on: https://gerrit.dechocorp.com/26665
Reviewed-by: Andrew Skowronski <andrews@mozy.com>
Reviewed-by: Kevin Cai <kcai@vmware.com>
tfixes #45879  Refactor the socket code to resemble 2.8 code

These changes seem to fix the problem with the socket hanging when we run under panda.
We are waiting to hear from panda on a hot-fix on their side, but in case that doesn't work then we may need to use our fix.

Change-Id: I3187fc900e344c249c760ca74d1e809c70b21f9c
Reviewed-on: https://gerrit.dechocorp.com/26627
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
Reviewed-by: Russ Simons <russs@mozy.com>
add simple xml parser for atmos stuff

partially implements DOM

Change-Id: Ib0d96c9c02f151066002c97dc9407cb3588fe8bc
Reviewed-on: https://gerrit.dechocorp.com/26726
Reviewed-by: Jeremy Stanley <jeremy@mozy.com>
Reviewed-by: Kevin Cai <kcai@vmware.com>
Recover from ERROR_BUFFER_OVERFLOW on GetAdaptersAddressest

tfixes #46951 - Dependent on kalypso changes

Change-Id: I7747928bad655587bc8e6d03a0c6806e76c60f2d
Reviewed-on: https://gerrit.dechocorp.com/26928
Reviewed-by: Henry Chen <hchen@vmware.com>
Ignore simpleappserver.

Change-Id: Ie3183e276dcf7b0ee8e438f08eeb88327f6a74b4
Reviewed-on: https://gerrit.dechocorp.com/27630
Reviewed-by: Kevin Harris <kevinhar@mozy.com>