Commit graph

815 commits

Author SHA1 Message Date
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
Vikram Rajkumar
5fa3cb8632 Add < operation to private_key to allow usage as an ordered key 2014-10-02 12:55:20 -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
Nikolai Mushegian
439232f750 Merge pull request #40 from dbrock/master
Compare HTTP headers case-insensitively
2014-09-17 16:53:04 -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
Vikram Rajkumar
d44d72b0d9 Merge pull request #39 from dbrock/master
Use set_reuse_addr in http_server
2014-09-15 15:00:34 -04:00
Daniel Brockman
7b8394a781 Use set_reuse_addr in http_server 2014-09-15 20:30:31 +02:00
Nikolai Mushegian
b0c68813cb Merge pull request #38 from InvictusInnovations/revert-37-master
Revert "Set SO_REUSEADDR to avoid having to wait for network ports to be...
2014-09-15 14:06:43 -04: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
Nikolai Mushegian
59c6882b03 Merge pull request #37 from dbrock/master
Set SO_REUSEADDR to avoid having to wait for network ports to be released when restarting the client
2014-09-15 14:04:49 -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
Nathan Hourt
21db937ba7 Add reflector for multimap 2014-09-04 19:14:23 -04:00
Eric Frias
a0b3a9a92d Restore function-like semicolon-swallowing behavior to FC_THROW 2014-09-02 15:21:30 -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
477d3397f6 Merge branch 'log_task_names' 2014-08-28 15:29:14 -04:00
Eric Frias
da15557c85 assert() instead of throwing fc::null_optional exception when dereferencing an invalid optional. Before, the behavior was to throw null_optional in debug mode and to allow the dereference in release, which masked the error 2014-08-28 11:42:46 -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