Commit Graph

44 Commits

Author SHA1 Message Date
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Mike Gelfand 27b6884408 Move uTP timer to session struct 2017-07-02 13:31:33 +03:00
Mike Gelfand 18aabdeb06 Introduce peer socket struct to improve readability 2017-06-28 18:50:05 +03:00
Mike Gelfand 98695fe3c1 Introduce our own assertion macros with finer control 2017-06-08 10:24:12 +03:00
Mike Gelfand 501be27972 Reduce code duplication in logging macros 2017-05-22 23:20:28 +03:00
Mike Gelfand a762c770f2 Make conditional expressions explicitly boolean 2017-04-30 19:26:01 +03:00
Mike Gelfand 4f9d9ad92b Code style change leftovers
For some reason, GTK client wasn't fully processed. All the rest of changes
are mostly in comments.
2017-04-21 10:40:57 +03:00
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
2017-04-20 19:53:20 +03:00
Mike Gelfand d7930984ef Adjust uncrustify config, reformat all but Mac client
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).

The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.
2017-04-20 10:01:22 +03:00
Mike Gelfand eb8fc35ac6 Remove useless checks and definitions (C99)
Now that MSVC support for C99 is quite good, remove previously needed but
now unused checks and definitions, like PRI* format macros (including
PRIdMAX and TR_PRIuSIZE, replaced with %jd and %zu) and inline macro.
Also, remove ssize_t typedef and replace few occurences with ev_ssize_t.
Also, remove check for stdbool.h availability (guaranteed by C99) and
include it unconditionally (except when in C++ mode).
2015-12-29 19:37:31 +00:00
Mike Gelfand 949e02b933 Define and use tr_socket_t and TR_BAD_SOCKET instead of int and -1.
Test socket validity by comparing to TR_BAD_SOCKET instead of various
(and sometimes wrong) other tests like `x >= 0`, `x != -1`, `x > 0`,
`x > -1`, `x` (valid), and `x < 0`, `x == -1` (invalid).
2015-03-18 07:34:26 +00:00
Mike Gelfand 9a3b965ce4 Kill some warnings when compiling on Windows 2015-01-02 04:02:13 +00:00
Mike Gelfand 52a9d774e4 Fix compilation on Windows
This should not affect non-Win32 platforms in any way.
As for Win32 (both MinGW and MSVC), this should hopefully allow for
unpatched compilation. Correct functioning is not yet guaranteed though.
2014-12-13 15:22:39 +00:00
Mike Gelfand f6f7bf8227 #4400, #5462: Move random helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing random numbers/data generation to crypto-utils.{c,h}. OpenSSL-
related functionality (generation of cryptographically strong random
data) is moved to crypto-utils-openssl.c.

Rename functions to follow currently accepted style:
* tr_cryptoRandBuf -> tr_rand_buffer
* tr_cryptoRandInt -> tr_rand_int
* tr_cryptoWeakRandInt -> tr_rand_int_weak

Fix rare case of invalid value being returned from tr_rand_int. Return
value for abs(INT_MIN) may be undefined and thus negative, and so
tr_rand_int will return negative value which is incorrect (out of
requested and expected range).
2014-12-04 11:27:38 +00:00
Jordan Lee ea7d2482dd introduce TR_PRIuSIZE macro for portable printf()ing of size_t. mikedld 2013-09-08 17:32:09 +00:00
Jordan Lee f75027d5e9 make all the log functions/structs/enums use a single 'tr_log' namespace, such as tr_logGetQueue, tr_logAddInfo, tr_logIsLevelActive 2013-01-25 23:34:20 +00:00
Jordan Lee 3d38723ad9 Follow more common whitespace style conventions in the C code (libtransmission, daemon, utils, cli, gtk). 2012-12-05 17:29:46 +00:00
Jordan Lee d717248e75 (trunk libT) fix the Linux build wrt compiling with the new snapshot of libutp checked into r13317
Previously we made sure to include stdbool.h (via transmission.h) before utp.h, since the latter used 'bool' without defining it. The new snapshot defines it unconditionally in non-C++ code, so now we need to include it first.
2012-05-30 17:47:29 +00:00
Jordan Lee 2786136015 (trunk) #4490 "Transmission 2.40b1 fails to build: undefined references" -- fixed. 2011-10-08 23:53:27 +00:00
Jordan Lee 1b825079be (trunk libT) API cleanup of the tr_address functions to make them more consistent.
This is loosely related to #2910, but only in the sense of laying the groundwork for #2910's fix...
2011-03-25 05:34:26 +00:00
Jordan Lee 1304aa0079 (trunk libT) still fiddling around with #includes -- this time removing unncecessary libT includes from libT .c files 2011-03-25 01:41:57 +00:00
Jordan Lee 324f0f470c (trunk libT) copyediting: '#include "crypto.h"' cleanup 2011-03-25 01:21:31 +00:00
Jordan Lee 375694eda9 (trunk) copyediting: remove some unneeded #includes, and annotate some needed ones 2011-03-24 21:49:42 +00:00
Jordan Lee b4d36aeb54 (trunk) #4138 "use stdbool.h instead of tr_bool" -- done. 2011-03-22 15:19:54 +00:00
Jordan Lee f4b4ddd231 (trunk libT) better shutdown management of libutp and UDP trackers in tr_sessionClose().
This is a little overlapping since the utp code can be closed more-or-less immediately, but the udp manager needs to stay open in order to process the udp tracker connection requests before sending out event=stopped. Moreover DNS resolver can be shut down after the UDP tracker is shutdown.
2011-03-17 18:51:31 +00:00
Jordan Lee 9bf2434e14 (trunk) copyediting: remove trailing spaces from source code lines in daemon/ gtk/ libtransmission/ and utils/ 2011-03-04 23:26:10 +00:00
Jordan Lee 3fdd80eb0d (trunk libT) new function: tr_ssToAddr()
This handles converting the data in a sockaddr_storage to a tr_address + port, and removes redundant code from fdlimit.c and tr-udp.c that previously did this work.
2011-03-04 21:00:52 +00:00
Jordan Lee 020bde5ce6 (trunk libT) a bit of futzing: remove a few more unnecessary casts from void* 2011-03-03 21:51:11 +00:00
Juliusz Chroboczek e7fc697c90 Stub out UTP_Create in non-uTP builds. 2011-02-18 16:01:52 +00:00
Jordan Lee b930026c40 (trunk libT) explicitly use the libevent2 header files, instead of the deprecated backwards-compatibility one 2011-02-18 01:25:32 +00:00
Jordan Lee cba90ccace (trunk libT) add stubs for UTP_Drained() and UTP_Write() to remove a few #ifdefs from peer-io.c 2011-02-18 01:18:51 +00:00
Jordan Lee 8e87147c61 (trunk libT) add a stub for UTP_Close() s.t. peer-mgr.c doesn't need the #ifdefs from r11960 2011-02-18 01:06:42 +00:00
Jordan Lee cd04051de8 add configure script switch to enable/disable utp 2011-02-18 00:45:44 +00:00
Juliusz Chroboczek 5ba2e40f79 When uTP is disabled, don't call UTP_CheckTimeouts too often. 2011-02-18 00:43:27 +00:00
Jordan Lee 75badcd4ab silence compiler warning 2011-02-18 00:40:53 +00:00
Juliusz Chroboczek 456dbdd935 Export uTP send_to callback. 2011-02-18 00:36:16 +00:00
Juliusz Chroboczek 51bc8d8b80 Push testig for UTP enabled further down.
There's no need to test for DHT/uTP being enabled in tr-udp.  The DHT
will silently discard any packets directed at the wrong session (see the
beginning of dhtCallback).  As to uTP, we need to grok uTP packets
to close any remaining connections after we disabled uTP, so it's better
to participate in uTP, just reject any incoming connections.
2011-02-18 00:35:56 +00:00
Jordan Lee c4b1d1e6c5 (trunk libT) add C and RPC API for getting/setting uTP enabled flag 2011-02-18 00:33:11 +00:00
Jordan Lee 7df7d34f6d automake/autoconf; #includes in libtransmission 2011-02-18 00:32:19 +00:00
Juliusz Chroboczek 1cfa2ac38b Update tr-utp.c to be compatible with libevent2. 2011-02-18 00:24:11 +00:00
Juliusz Chroboczek 87d1f5ca34 Check for UTP timeouts every 50ms or so.
Greg says that works for them.
2011-02-18 00:24:04 +00:00
Juliusz Chroboczek 7741151c48 Accept UTP connexions. 2011-02-18 00:23:58 +00:00
Juliusz Chroboczek 98ea0addb0 Fix incorrect use of tr_timerAdd. 2011-02-18 00:23:49 +00:00
Juliusz Chroboczek c5e3cfecb9 Participate in UTP.
This adds code to participate in the UTP protocol, but without doing anything
useful yet -- we just shut down immediately any incoming connexion request.
2011-02-18 00:23:47 +00:00