Commit graph

647 commits

Author SHA1 Message Date
Daniel Larimer
74b707999c fix bugs with websocket and integrate API support 2015-03-27 16:29:33 -04:00
Daniel Larimer
b8d7d3012d abstracting rpc state 2015-03-26 18:17:47 -04:00
Daniel Larimer
41fedc14f3 Merge branch 'master' of github.com:BitShares/fc 2015-03-26 16:51:15 -04:00
Daniel Larimer
4ce26f068f implement simple websocket wrapper ontop of websocketpp 2015-03-26 16:51:10 -04:00
Vikram Rajkumar
3d17836a1e Remove extraneous log config setting 2015-03-25 20:07:19 -04:00
Nathan Hourt
4194a609c2 Allow hashing of uint128 2015-03-06 16:41:52 -05:00
Daniel Larimer
73c2c1de90 fix static_variant to/from variant 2015-03-05 09:54:33 -05:00
Daniel Larimer
374f141f0a Merge branch 'master' of github.com:BitShares/fc 2015-02-23 14:02:06 -05:00
Daniel Larimer
537029f09f fix build 2015-02-23 14:01:58 -05:00
Vikram Rajkumar
c3bc573af7 Fix Mac build 2015-02-23 11:08:55 -05:00
SynaptiCAD User
42fcebd473 Remove unnecessary locking around log sending 2015-02-22 14:07:27 -05:00
SynaptiCAD User
30e52b6b01 Fix GELF logging to split long messages, use compression 2015-02-22 14:07:05 -05:00
Daniel Larimer
ec66863902 added type for safe int ops 2015-02-19 11:39:17 -05:00
Daniel Larimer
cf4ed08d4b Merge branch 'master' of github.com:BitShares/fc 2015-02-17 09:55:36 -05:00
Daniel Larimer
93a789891e Adding is_utf8 call and making enum_type cast explicit 2015-02-17 09:55:31 -05:00
Nathan Hourt
c7de8954fb Merge branch 'master' of github.com:bitshares/fc 2015-02-12 10:55:12 -05:00
Nathan Hourt
de2000795d Fix crashes when destroying json_connection, tcp_socket
Also, create on_close callback on json_connection, so clients can
know when the connection has failed.
2015-02-12 10:54:18 -05:00
Vikram Rajkumar
ee370dd5a8 Define sha256::hash( sha256 ) 2015-02-11 18:58:19 -05:00
Nathan Hourt
13430fce12 Revert "Dumb hack that seems to prevent crashing when destroying json_connection"
This reverts commit b068865eb5.
Caused crashes elsewhere.
2015-02-11 17:20:58 -05:00
Nathan Hourt
b068865eb5 Dumb hack that seems to prevent crashing when destroying json_connection 2015-02-10 18:35:50 -05:00
Vikram Rajkumar
9c5450185a Revert "Pretty-print objects in log messages"
This reverts commit 41630e7629.
2015-02-05 18:52:59 -05:00
Vikram Rajkumar
41630e7629 Pretty-print objects in log messages 2015-02-04 18:05:28 -05:00
Vikram Rajkumar
43659333d3 Fix compiler warning 2015-02-03 18:12:37 -05:00
theoretical
323d59b054 real128: Rename PRECISION to FC_REAL128_PRECISION and expose it globally 2015-02-03 11:31:20 -05:00
theoretical
51033bcb12 real128: Implement from_fixed() to initialize real128 from fixed point value 2015-02-03 11:23:22 -05:00
theoretical
4b8c211629 uint128: Check for large shift count before truncating in << and >>
- Correctly handle very large shift counts
- uint128(1) << (uint64_t(1) << 32) should now be 0 as expected
2015-01-30 13:19:01 -05:00
Nathan Hourt
ac197311ca json_connection: save and cancel a future
Hopefully this will fix a crash on exit.
2015-01-30 10:23:33 -05:00
theoretical
d963c6482a Protect flush() with lock in json_connection.cpp
- Maybe fixes https://github.com/BitShares/bitshares/issues/1323
2015-01-29 12:55:34 -05:00
Eric Frias
a33bb60cf6 Add a simplified lock file class to use to prevent two applications from using the same resource 2015-01-21 19:29:38 -05:00
theoretical
0642eb63d3 Throw more appropriate exception type in from_base58 2015-01-21 14:57:04 -05:00
SynaptiCAD User
859282305d Better format log message context 2015-01-21 09:50:14 -05:00
Eric Frias
f3065b367e Add log appender that sends logs in GrayLog Extended Log Format 2015-01-20 16:13:26 -05:00
Vikram Rajkumar
e1678b1801 Add missing default HTTP response 2015-01-19 17:38:28 -05:00
theoretical
64c6c01b80 more efficient uint128 multiplication algorithm (measured 29.23x speedup) 2015-01-07 14:57:45 -05:00
theoretical
6ecb55ac2e Implement full product for uint128 * uint128 -> 256-bit result 2015-01-07 11:20:34 -05:00
drltc
40943808d0 Initial implementation of relaxed JSON parser (not fully tested) 2015-01-02 10:37:16 -05:00
theoretical
524093ce1e Implement chmod function (no-op on Windows) 2014-12-31 14:42:36 -05:00
Eric Frias
5a91c4f118 Virtualize a few functions in istream to allow them to be overridden in derived classes 2014-12-22 17:56:30 -05:00
drltc
594ef43f76 Wrap boost exceptions thrown by to_int64, to_uint64, to_double 2014-12-15 15:40:35 -05:00
drltc
43e02caa79 Fix typo in 64-bit integer variant constructor on Linux 2014-12-15 15:40:21 -05:00
Vikram Rajkumar
36baae683e Minor spelling fix 2014-12-11 19:16:02 -05:00
Daniel Larimer
cb66666edd Merge branch 'master' of github.com:BitShares/fc 2014-12-10 22:58:53 -08:00
Daniel Larimer
a4a90fac05 Update to elliptic curve signature verification 2014-12-10 22:43:37 -08:00
drltc
16c0709500 Increase stack size to 2MB 2014-11-19 11:27:22 -05:00
Vikram Rajkumar
e29438461e Revert "Temporarily revert timestamp serialization change to upgrade in phases"
This reverts commit c38479c6ae.
2014-11-12 14:12:56 -05:00
Daniel Larimer
e6b43a6149 adding support for 10 arg rpc calls 2014-11-10 18:29:05 -05:00
dnotestein
27ac054883 Log thread creation and destruction 2014-11-03 16:59:19 -05:00
dnotestein
13d536c119 Prevent crash at shutdown by shutting down rate_limiting asyncs before boost filesystem global constructors execute. 2014-10-31 17:54:14 -04:00
Vikram Rajkumar
c38479c6ae Temporarily revert timestamp serialization change to upgrade in phases 2014-10-29 15:01:24 -04:00
Vikram Rajkumar
f948bd759d Use ISO standard delimited timestamp string serialization 2014-10-28 18:54:49 -04:00
Eric Frias
307252e23a Call fc:🧵:quit() on thread destruction, and remove code that explicitly terminates threads from the destructors of the objects that own those threads.
Fix fc::thread to set the thread name in the Debugger when the name is set after thread construction.
When terminating a thread, cancel any tasks that have been schedule()d or async()ed but have not yet started executing.
When canceling a task blocked on a fc::mutex, notify the thread to reschedule the task to allow it to clean up the mutex's block list.
Fix a bug in managing the recursive lock count when tasks block on a fc::mutex
Reorder the code that manages the hard links for log files to avoid an exception generated by unlinking a locked file on Windows.
2014-10-21 10:25:28 -04:00
Nathan Hourt
c1eca45ef1 More fixes in json_connection 2014-10-20 12:52:47 -04:00
Eric Frias
891e880ad1 When the HTTP server asyncs a handler for a request, keep a future for that async and cancel any running asyncs when the HTTP server destructs 2014-10-17 16:18:55 -04:00
Nathan Hourt
fadc0512a1 Merge branch 'master' of github.com:InvictusInnovations/fc 2014-10-17 13:43:46 -04:00
Nathan Hourt
502a3c653c Fix yield in catch block 2014-10-17 13:43:40 -04:00
Vikram Rajkumar
7ddf882459 Fix linux build 2014-10-17 13:23:51 -04:00
Eric Frias
b026e82451 Remove task priority hack that is no longer needed 2014-10-17 12:04:21 -04:00
Eric Frias
227767a425 Fix type of PRECISION 2014-10-16 19:00:30 -04:00
Eric Frias
b34a222dc5 Remove #ifdefed-out code 2014-10-16 17:50:58 -04:00
Eric Frias
e5666cca54 Convert ready_head (list of fibers able to run immediately) into a priority heap 2014-10-16 16:26:19 -04:00
Eric Frias
95eb84e62d Add missing include 2014-10-16 16:25:12 -04:00
Eric Frias
1af4ac6a5c Schedule fibers in the order they are asynced or unblocked. Earlier behavior was always to start newly-asycned tasks before resuming existing tasks, so existing tasks could be starved if there was a steady stream of new tasks created. Now all tasks are started or resumed in the order they are created or unblocked. 2014-10-16 15:25:31 -04:00
Eric Frias
a426bf9710 whitespace and spelling fixes, no functional changes 2014-10-16 15:25:31 -04:00
Daniel Larimer
dfe67a4494 adding blob type to variant 2014-10-15 23:32:37 -04:00
Daniel Larimer
ec9e85d268 fix fixed point math 2014-10-15 20:46:24 -04:00
Nathan Hourt
c3a6b40188 Test and bugfix real128 2014-10-15 17:53:50 -04:00
Daniel Larimer
b55ae3431a adding real 128 for fixed point 64.64 math 2014-10-15 17:00:49 -04:00
Nathan Hourt
1a78fd2931 Add directory_size call
Recursively iterate the specified directory, summing up the files
inside, and return the total size.
2014-10-13 15:17:14 -04:00
Eric Frias
b63e6a8b81 Allow recursive fc::mutexes 2014-10-12 17:28:41 -04:00
Eric Frias
4e83427df0 Improvements for handling unicode filenames on Windows. When converting fc::path to/from fc::variant, use utf8 encoding. Replace several places where we use a std::ifstream and open it with a char* filename with a boost::filesystem::ifstream and open it with a boost::filesystem::path, which does unicode correctly. 2014-10-09 16:21:52 -04:00
Eric Frias
06ca6d8981 Fix bug that was causing NTP to fail to update after the first check 2014-10-07 11:49:35 -04:00
Eric Frias
82dd74add0 Retry NTP requests more frequently if we don't receive a (valid) reply 2014-10-07 11:10:27 -04:00
Eric Frias
0d61966a1c Improve NTP math 2014-10-07 10:31:19 -04:00
Eric Frias
5a615e6b21 Execute async tasks in the order they were asynced (this only changes the behavior of tasks that hadn't started executing yet, it doesn't change anything about the order blocked tasks unblock) 2014-10-03 16:53:14 -04:00
Eric Frias
256df78fc6 Allow binaries compiled on a system that doesn't support SO_REUSEPORT to use the option
on systems that do support it
2014-10-02 14:49:38 -04:00
dnotestein
c4e814d7de Added more logging to ntp and fixed code indentation. 2014-09-30 10:53:23 -04:00
dnotestein
53196706f0 Add some more logging to ntp time synchronization code. 2014-09-29 18:55:35 -04:00
Eric Frias
8def04f341 Add a path::preferred_string() function that generates a string in the platform's preferred format, using backslashes on win32 (uses boost::filesystem::path::make_preferred()).
Modify the log file configuration and rotating code to call to_native_ansi_path() and do more paths manipulation in fc::path objects and less in std::strings, in an attempt to improve BitShares/bitshares_toolkit#791
2014-09-25 08:57:31 -04:00
Eric Frias
6cddd42cfe On windows, change the method we use for getting the home directory and app data directory to get it in unicode form. Partial fix for BitShares/bitshares_toolkit#791 2014-09-20 19:15:28 -04:00
Eric Frias
2f066e4adf Fix a crash in fc::process when not capturing all three stdin/out/err
Quiet a few 64-bit warnings.
2014-09-18 11:17:41 -04:00
Daniel Brockman
bd846576f6 Compare HTTP headers case-insensitively
See <https://groups.google.com/d/msg/nodejs/XIU55IYtfJo/feUp9Fz7p14J>
2014-09-17 22:50:47 +02:00
Nathan Hourt
07e3947ed4 Fix bug in json pretty printer which broke formatting and possibly
corrupted json
2014-09-17 13:27:37 -04:00
Eric Frias
7966587021 Wrap a few boost asio exceptions in fc exceptions 2014-09-16 09:33:51 -04:00
Daniel Brockman
7b8394a781 Use set_reuse_addr in http_server 2014-09-15 20:30:31 +02:00
Nikolai Mushegian
60781c532b Revert "Set SO_REUSEADDR to avoid having to wait for network ports to be released when restarting the client" 2014-09-15 14:06:37 -04:00
Daniel Brockman
9ba96f9dcf Set SO_REUSEADDR 2014-09-15 20:02:27 +02:00
Eric Frias
b5414af3ce Restore an accidentally-commented-out line that was preventing NTP from restarting after encountering an error. 2014-09-14 19:53:08 -04:00
Eric Frias
3ee5f756fb Fix a yield-during-catch bug in udp_socket, and add a shared_ptr version of udp_socket::send_to() which will avoid reading from uninitialized memory in the face of cancellation. 2014-09-12 19:42:25 -04:00
Eric Frias
1daaab43ac Add assert to catch any time we yield during a catch{} block 2014-09-12 14:28:56 -04:00
Eric Frias
751777e754 Fix more locations where we were making boost::asio calls with buffers declared on the stack which could cause problems when the calling tasks were canceled. 2014-09-11 16:30:03 -04:00
Nathan
55e7a073cf Fix build error in salsa20.cpp 2014-09-09 16:09:49 -04:00
Eric Frias
aa6882b3b7 Allow us to safely cancel tasks that are executing asynchronous network reads
and writes.  This was previously unsafe because we almost always passed read/write
buffers to boost that were on the stack. Canceling the task deleted the stack and
therefore the buffer, but couldn't reliably prevent boost from writing to the buffer
if data came in after the cancel.  This commit adds variants of the read and write
functions that take a shared_ptr<char> instead of a raw char* as the buffer, and
these variants will ensure the shared_ptr will outlive the boost::asio read/write.
2014-09-09 11:10:37 -04:00
Eric Frias
db8eb2e5d4 Revert "Instead of canceling the read_loop, close the socket and wait for the read_loop to finish as a result. This prevents the receive_from from writing into the buffer (which is on the stack!) after the task is canceled. This caused nasty intermittent exception stack unwind errors."
This reverts commit c79cbdae8e.
2014-09-09 11:08:27 -04:00
dnotestein
c79cbdae8e Instead of canceling the read_loop, close the socket and wait for the read_loop to finish as a result. This prevents the receive_from from writing into the buffer (which is on the stack!) after the task is canceled. This caused nasty intermittent exception stack unwind errors. 2014-09-08 17:23:03 -04:00
Eric Frias
881903c1be Wrap boost::exception with fc::exception in fc::ip::endpoint::from_string()
Restructure udp_socket::receive_from() to something functionally identical, but has one less exception handler on the stack which I hope would make it easier to debug strange exception-handling errors encountered on win64
2014-09-08 16:10:42 -04:00
dnotestein
10fdbcf5b3 Dequeue a thread from a blocking promise's notify list when the all the thread's tasks that are waiting on that promise are canceled. This prevents a crash when the promise is fulfilled after the thread is destroyed.
Re-organize read-loop execution to avoid crashes in read_loop on Win32 when ntp object destructs. Call quit on ntp_thread when ntp object destructs to free up thread (eventually we need to make fc::threads call quit in their destructor, but more work is required to make that work properly).
~fc::udp_socket now closes socket on destruction (consider doing this for tcp sockets as well).
2014-09-08 15:31:13 -04:00
dnotestein
1360eabd8c Merge branch 'master' of https://github.com/InvictusInnovations/fc 2014-09-08 10:47:16 -04:00
Eric Frias
130da3623e Allow fibers to be canceled while they're sleeping or blocked on promises 2014-09-08 10:41:59 -04:00
Eric Frias
454573e048 Add support for boost 1.56. 2014-09-08 10:41:59 -04:00
Nathan Hourt
9b6facea3f Make the JSON parser less fragile 2014-09-08 10:12:42 -04:00
dnotestein
b6e38cd5ec Eliminate unnecessary cast in endpoint::from_string 2014-09-08 10:10:19 -04:00
Eric Frias
3222dc7c0b When reusing a context, re-initialize most of its fields. This fixes at least two errors:
- we were canceling tasks that hadn't been canceled, because the canceled flag was left set to true and the next task assigned to the context then became canceled as soon as it yielded
 - we were resumeing blocked tasks before they should have resumed, because their blocking_promises list wasn't cleared and they were unblocking because the erroneous promises were fulfilled
As a debugging aid, we also record the cancellation reason whenever a task is canceled, and include that in the canceled_exception (this is only enabled in debug builds)
2014-08-28 15:43:26 -04:00
Eric Frias
f8472af119 Change fc::canceled_exceptions thrown due to a socket operation being canceled into regular fc::exceptions -- we're reserving canceled_exception for canceling async tasks 2014-08-28 15:34:04 -04:00
Eric Frias
ac385d1f6b Allow the user to supply a reason string when canceling a task (useful for debugging) 2014-08-27 14:07:44 -04:00
Eric Frias
8841f5e271 Import thread/task_specific variables 2014-08-27 12:20:19 -04:00
Eric Frias
d9e6a9e568 When a task is canceled while blocking on a mutex, fix the code that removes it from the mutex's block list to null out its "next" pointer, which is assumed to be null whenever not blocked on a mutex 2014-08-27 11:55:14 -04:00
Eric Frias
976bbce668 When locking a mutex, ensure the task has a context before attempting to lock. 2014-08-25 18:44:15 -04:00
Eric Frias
d188b138d6 Allow fc::canceled_exception to pass through places where we were catching and ignoring all fc::exceptions 2014-08-25 18:43:12 -04:00
Eric Frias
27096f15a7 Log the names of tasks to the log file (now contains thread_name:task_name} 2014-08-24 18:33:05 -04:00
Eric Frias
198d858d59 Wrap boost exceptions in fc exceptions for a few socket operations that can throw 2014-08-24 14:47:01 -04:00
Eric Frias
578527626c Support GNTP password authentication 2014-08-21 19:32:56 -04:00
Eric Frias
156a7cc4b4 Allow setting hostname 2014-08-21 16:14:08 -04:00
Eric Frias
362884fc52 Import GNTP notification code 2014-08-21 15:21:48 -04:00
Nathan Hourt
9e75d47ba3 Fix to an issue causing a thread to exit if any fiber therein self-cancels 2014-08-21 14:36:29 -04:00
Daniel Larimer
8468f392ce default to_string conversion is now fixed 2014-08-13 16:06:42 -04:00
Eric Frias
92d29ac657 Prevent crash at shutdown rescheduling NTP task 2014-08-12 15:19:44 -04:00
Eric Frias
978de7885a Add a macro to check if a task that shouldn't yield actually yields. 2014-08-02 19:43:28 -04:00
Daniel Larimer
6e31ffd963 Merge branch 'master' of https://github.com/InvictusInnovations/fc 2014-08-01 17:21:24 -04:00
dnotestein
7cc69f3bb7 Set canceled flag in task's context object so that we cancel out of active tasks when they try to resume. Wrap a try-catch block around tcp and udp resolve requests to convert any non-fc exceptions to fc exceptions. Minor change to clarify design intent that request_time_task should always be running in _ntp_thread. 2014-08-01 11:31:36 -04:00
PaulEU
eae493a8c1 Remove unnecessary code from init_openssl after update new OpenSSL package. 2014-07-29 23:44:47 +02:00
Daniel Larimer
3ccbe26dd5 adding aes exception 2014-07-29 13:54:50 -04:00
Vikram Rajkumar
a23f3a86be Add missing integer variant conversions 2014-07-28 22:36:47 -04:00
Eric Frias
d847f6469a Allow us to require assigning descriptions to all async tasks to aid in debugging 2014-07-27 17:37:21 -04:00
dnotestein
9e320a3db8 Add descriptions for a bunch of async tasks, remove logging during thread::quit to avoid crashes for now until we cleanup thread quit code 2014-07-27 00:09:15 -04:00
Vikram Rajkumar
3be05ef822 Merge branch 'master' of github.com:InvictusInnovations/fc 2014-07-26 22:29:22 -04:00
Vikram Rajkumar
48837f3116 Add time_point_sec::to_iso_{extended_}string() 2014-07-26 21:05:11 -04:00
Eric Frias
b460fd6b41 Cleanup all async tasks on exit, thread safety, work in progress. 2014-07-26 18:22:38 -04:00
Eric Frias
600ae24657 separate one try/catch into two blocks during file_appender destructor 2014-07-26 15:05:26 -04:00
Eric Frias
c208a968b2 Fix ntp on win32 2014-07-25 14:40:47 -04:00
dnotestein
34296fbb4a Eliminate local variable that was shadowing data member variable stack_ctx in context object, which resulted in an assert when the context object was destructed. 2014-07-24 15:18:53 -04:00
Nathan Hourt
a254e5ff28 Merge branch 'master' of github.com:InvictusInnovations/fc 2014-07-23 11:59:48 -04:00
Nathan Hourt
523fa56d88 Bugfix: Incorrect ordering of newline and carriage return in HTTP server
The HTTP server was printing "\n\r" at the end of lines in the response
headers, which is invalid and caused some HTTP clients to detect an end
to the headers after the first header line.

The server now prints the proper "\r\n" sequence, which is parsed
correctly by clients.
2014-07-23 11:56:57 -04:00
PaulEU
4890351b34 Added OpenSSL configuration file path. (qt_wallet issue #10 Some clients on Windows 7 quit/crash on start) 2014-07-23 00:18:09 +02:00
Daniel Larimer
6ef73a4198 reduce default stack size by 50% to 4x default from 8x 2014-07-17 23:03:23 -04:00
Daniel Larimer
eed62c8338 sockets now wait for any pending write or read operations to finish before destructing 2014-07-17 17:03:25 -04:00
Daniel Larimer
01202aa709 adding space to exception message 2014-07-16 14:20:36 -04:00
Eric Frias
b6f8570c35 Lock mutex during more of the log rotation process (attempting to prevent crashes that have been seen while logging at the same time as log rotation) 2014-07-16 13:39:14 -04:00
grzegorzs
06fe9e0303 [GS] Fix types u_int32_t to uint32_t etc. - continued 2014-07-15 14:20:42 +02:00
Vikram Rajkumar
e442b29f6e Fix scrypt 2014-07-14 13:40:33 -04:00
Eric Frias
a034239313 Add missing include 2014-07-07 12:36:34 -04:00
Eric Frias
62ea4ae9c3 Add mutexes to make OpenSSL thread safe 2014-07-07 12:22:01 -04:00
Vikram Rajkumar
18611eccb9 Fix log rotation scheduling bug 2014-07-05 16:22:25 -04:00
Daniel Larimer
ace06d775c support for 8 param rpc calls 2014-07-04 17:23:47 -04:00
Vikram Rajkumar
c9c56ffbb6 Merge branch 'master' of https://github.com/InvictusInnovations/fc 2014-07-03 17:24:14 -04:00
Vikram Rajkumar
e9b1b8ec2e Use a separate thread for log compression 2014-07-03 17:24:06 -04:00
Eric Frias
c020913cb8 Make process::exec take an 'int' for the bitmask of launch options instead of an enum to make it more clear that it's a bitmask (and avoid a cast) 2014-07-03 09:30:50 -04:00
Vikram Rajkumar
adf8c10ee5 Fix Linux compilation 2014-07-03 02:55:30 -04:00
Vikram Rajkumar
223f0005f5 Hardlink from most recent log to original filename during rotation 2014-07-03 02:55:30 -04:00
Vikram Rajkumar
b522f12a0e Use ISO format timestamps for rotated log files 2014-07-03 02:17:03 -04:00
Vikram Rajkumar
b1e677bcee Implement optional LZMA compression for rotated logs 2014-07-03 01:27:58 -04:00