Permalink
Browse files

added brake line option (options+=--max-code-length=120)

  • Loading branch information...
badrock committed May 31, 2014
1 parent 2e2da15 commit 320bf248f3cde0313e982ab9b26ae86d2017b8c7
Showing with 361 additions and 172 deletions.
  1. +26 −13 NativeLib.cpp
  2. +15 −7 api.cpp
  3. +4 −2 avail.cpp
  4. +2 −1 avgspeed.cpp
  5. +32 −16 binmap.cpp
  6. +10 −5 binmap.h
  7. +2 −1 channel.cpp
  8. +12 −6 cmdgw.cpp
  9. +2 −1 compat.cpp
  10. +4 −2 content.cpp
  11. +4 −2 ext/live_picker.cpp
  12. +2 −1 ext/vod_picker.cpp
  13. +8 −4 exttrack.cpp
  14. +2 −1 hashtree.cpp
  15. +22 −10 httpgw.cpp
  16. +6 −3 live.cpp
  17. +20 −10 livehashtree.cpp
  18. +12 −6 livesig.cpp
  19. +2 −1 livesig.h
  20. +2 −1 send_control.cpp
  21. +51 −25 sendrecv.cpp
  22. +3 −1 statsgw.cpp
  23. +10 −5 storage.cpp
  24. +20 −9 swarmmanager.cpp
  25. +6 −2 swarmmanager.h
  26. +34 −17 swift.cpp
  27. +38 −15 swift.h
  28. +2 −1 tests/livepptest.cpp
  29. +4 −2 transfer.cpp
  30. +2 −1 zerohashtree.cpp
  31. +2 −1 zerostate.cpp
View
@@ -27,7 +27,8 @@ using namespace swift;
#define ASYNC_POLL_INTERVAL (100*TINT_MSEC)
// httpgw.cpp functions
bool InstallHTTPGateway(struct event_base *evbase,Address bindaddr, popt_cont_int_prot_t cipm, uint64_t disc_wnd, uint32_t chunk_size, double *maxspeed, std::string storage_dir, int32_t vod_step, int32_t min_prebuf);
bool InstallHTTPGateway(struct event_base *evbase,Address bindaddr, popt_cont_int_prot_t cipm, uint64_t disc_wnd,
uint32_t chunk_size, double *maxspeed, std::string storage_dir, int32_t vod_step, int32_t min_prebuf);
bool HTTPIsSending();
std::string HttpGwGetProgressString(SwarmID &swarmid);
@@ -104,7 +105,8 @@ intstringmap_t asyncResMap; // protected by mutex
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_Init(JNIEnv * env, jobject obj, jstring jlistenaddr, jstring jhttpgwaddr)
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_Init(JNIEnv * env, jobject obj,
jstring jlistenaddr, jstring jhttpgwaddr)
{
dprintf("NativeLib::Init called\n");
@@ -164,7 +166,8 @@ JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_Init(JNI
// Playback via HTTP GW: Client should contact 127.0.0.1:8082/roothash-in-hex and
// that will call swift::(Live)Open to start the actual download
// 32 K steps and no minimal prebuf for Android
bool ret = InstallHTTPGateway(Channel::evbase,httpgwaddr,POPT_CONT_INT_PROT_MERKLE, DEFAULT_MOBILE_LIVE_DISC_WND_BYTES, chunk_size, maxspeed, "/sdcard/swift/", 32*1024, 0);
bool ret = InstallHTTPGateway(Channel::evbase,httpgwaddr,POPT_CONT_INT_PROT_MERKLE, DEFAULT_MOBILE_LIVE_DISC_WND_BYTES,
chunk_size, maxspeed, "/sdcard/swift/", 32*1024, 0);
if (ret == false)
errorstr = "cannot start HTTP gateway";
}
@@ -271,7 +274,8 @@ void AsyncSetResult(int callid, std::string result)
}
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGetResult(JNIEnv *env, jobject obj, jint jcallid)
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGetResult(JNIEnv *env, jobject obj,
jint jcallid)
{
int callid = (int)jcallid;
@@ -305,7 +309,8 @@ JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGet
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncOpen(JNIEnv * env, jobject obj, jstring jswarmid, jstring jtracker, jstring jfilename)
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncOpen(JNIEnv * env, jobject obj,
jstring jswarmid, jstring jtracker, jstring jfilename)
{
dprintf("NativeLib::Open called\n");
@@ -369,7 +374,8 @@ void LibeventOpenCallback(int fd, short event, void *arg)
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncClose(JNIEnv * env, jobject obj, jstring jswarmid, jboolean jremovestate, jboolean jremovecontent)
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncClose(JNIEnv * env, jobject obj,
jstring jswarmid, jboolean jremovestate, jboolean jremovecontent)
{
dprintf("NativeLib::Close called\n");
@@ -419,7 +425,8 @@ void LibeventCloseCallback(int fd, short event, void *arg)
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_hashCheckOffline(JNIEnv *env, jobject obj, jstring jfilename)
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_hashCheckOffline(JNIEnv *env, jobject obj,
jstring jfilename)
{
dprintf("NativeLib::hashCheckOffline called\n");
@@ -444,7 +451,8 @@ JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_hashChec
JNIEXPORT void JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_SetTracker(JNIEnv * env, jobject obj, jstring jtracker)
JNIEXPORT void JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_SetTracker(JNIEnv * env, jobject obj,
jstring jtracker)
{
if (!enginestarted)
return; // "Engine not yet initialized";
@@ -464,7 +472,8 @@ JNIEXPORT void JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_SetTracker(
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGetHTTPProgress(JNIEnv * env, jobject obj, jstring jswarmid)
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGetHTTPProgress(JNIEnv * env, jobject obj,
jstring jswarmid)
{
if (!enginestarted)
return -1; // "Engine not yet initialized"
@@ -501,7 +510,8 @@ void LibeventGetHTTPProgressCallback(int fd, short event, void *arg)
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGetStats(JNIEnv * env, jobject obj, jstring jswarmid)
JNIEXPORT jint JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_asyncGetStats(JNIEnv * env, jobject obj,
jstring jswarmid)
{
if (!enginestarted)
return -1; // "Engine not yet initialized"
@@ -542,7 +552,8 @@ void LibeventGetStatsCallback(int fd, short event, void *arg)
/*
* Create live swarm
*/
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_LiveCreate(JNIEnv *env, jobject obj, jstring jswarmid)
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_LiveCreate(JNIEnv *env, jobject obj,
jstring jswarmid)
{
if (!enginestarted)
return env->NewStringUTF("Engine not yet initialized");
@@ -582,7 +593,8 @@ JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_LiveCrea
* Add data to live swarm, to be turned into chunks when >=chunk_size has been
* added. Thread-safe because swift::LiveWrite uses an evtimer
*/
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_LiveAdd(JNIEnv *env, jobject obj, jstring jswarmid, jbyteArray dataArray, jint dataOffset, jint dataLength)
JNIEXPORT jstring JNICALL Java_com_tudelft_triblerdroid_swift_NativeLib_LiveAdd(JNIEnv *env, jobject obj,
jstring jswarmid, jbyteArray dataArray, jint dataOffset, jint dataLength)
{
if (!enginestarted)
return env->NewStringUTF("Engine not yet initialized");
@@ -634,7 +646,8 @@ void LibeventLiveAddCallback(int fd, short event, void *arg)
if (evbuffer_get_length(livesource_evb) > livesource_lt->chunk_size()) {
// Sufficient data to create a chunk, perhaps even multiple
size_t nchunklen = livesource_lt->chunk_size() * (size_t)(evbuffer_get_length(livesource_evb)/livesource_lt->chunk_size());
size_t nchunklen = livesource_lt->chunk_size() * (size_t)(evbuffer_get_length(
livesource_evb)/livesource_lt->chunk_size());
uint8_t *chunks = evbuffer_pullup(livesource_evb, nchunklen);
int nwrite = swift::LiveWrite(livesource_lt, chunks, nchunklen);
View
22 api.cpp
@@ -161,15 +161,19 @@ void swift::Shutdown()
*/
int swift::Open(std::string filename, SwarmID& swarmid, std::string trackerurl, bool force_check_diskvshash, popt_cont_int_prot_t cipm, bool zerostate, bool activate, uint32_t chunk_size, std::string metadir)
int swift::Open(std::string filename, SwarmID& swarmid, std::string trackerurl, bool force_check_diskvshash,
popt_cont_int_prot_t cipm, bool zerostate, bool activate, uint32_t chunk_size, std::string metadir)
{
if (api_debug)
fprintf(stderr,"swift::Open %s id %s track %s cdisk %d cipm %" PRIu32 " zs %d act %d cs %" PRIu32 "\n", filename.c_str(), swarmid.hex().c_str(), trackerurl.c_str(), force_check_diskvshash, cipm, zerostate, activate, chunk_size);
fprintf(stderr,"swift::Open %s id %s track %s cdisk %d cipm %" PRIu32 " zs %d act %d cs %" PRIu32 "\n",
filename.c_str(), swarmid.hex().c_str(), trackerurl.c_str(), force_check_diskvshash, cipm, zerostate, activate,
chunk_size);
if (swarmid.ttype() != FILE_TRANSFER)
return -1;
SwarmData* swarm = SwarmManager::GetManager().AddSwarm(filename, swarmid.roothash(), trackerurl, force_check_diskvshash, cipm, zerostate, activate, chunk_size, metadir);
SwarmData* swarm = SwarmManager::GetManager().AddSwarm(filename, swarmid.roothash(), trackerurl, force_check_diskvshash,
cipm, zerostate, activate, chunk_size, metadir);
if (swarm == NULL)
return -1;
else
@@ -776,10 +780,12 @@ int swift::HashCheckOffline(std::string filename, Sha1Hash *calchashptr, uint32_
* LIVE
*/
LiveTransfer *swift::LiveCreate(std::string filename, KeyPair &keypair, std::string checkpoint_filename, popt_cont_int_prot_t cipm, uint64_t disc_wnd, uint32_t nchunks_per_sign, uint32_t chunk_size)
LiveTransfer *swift::LiveCreate(std::string filename, KeyPair &keypair, std::string checkpoint_filename,
popt_cont_int_prot_t cipm, uint64_t disc_wnd, uint32_t nchunks_per_sign, uint32_t chunk_size)
{
if (api_debug)
fprintf(stderr,"swift::LiveCreate %s keypair checkp %s cipm %" PRIu32 " ldw %" PRIu64 " nsign %" PRIu32 " cs %" PRIu32 "\n", filename.c_str(), checkpoint_filename.c_str(), cipm, disc_wnd, nchunks_per_sign, chunk_size);
fprintf(stderr,"swift::LiveCreate %s keypair checkp %s cipm %" PRIu32 " ldw %" PRIu64 " nsign %" PRIu32 " cs %" PRIu32
"\n", filename.c_str(), checkpoint_filename.c_str(), cipm, disc_wnd, nchunks_per_sign, chunk_size);
// Arno: LIVE streams are not managed by SwarmManager
LiveTransfer *lt = new LiveTransfer(filename,keypair,checkpoint_filename,cipm,disc_wnd,nchunks_per_sign,chunk_size);
@@ -807,10 +813,12 @@ int swift::LiveWrite(LiveTransfer *lt, const void *buf, size_t nbyte)
}
int swift::LiveOpen(std::string filename, SwarmID &swarmid, std::string trackerurl, Address &srcaddr, popt_cont_int_prot_t cipm, uint64_t disc_wnd, uint32_t chunk_size)
int swift::LiveOpen(std::string filename, SwarmID &swarmid, std::string trackerurl, Address &srcaddr,
popt_cont_int_prot_t cipm, uint64_t disc_wnd, uint32_t chunk_size)
{
if (api_debug)
fprintf(stderr,"swift::LiveOpen %s hash %s track %s src %s cipm %" PRIu32 " ldw %" PRIu64 " cs %" PRIu32 "\n", filename.c_str(), swarmid.hex().c_str(), trackerurl.c_str(), srcaddr.str().c_str(), cipm, disc_wnd, chunk_size);
fprintf(stderr,"swift::LiveOpen %s hash %s track %s src %s cipm %" PRIu32 " ldw %" PRIu64 " cs %" PRIu32 "\n",
filename.c_str(), swarmid.hex().c_str(), trackerurl.c_str(), srcaddr.str().c_str(), cipm, disc_wnd, chunk_size);
// Help user
if (cipm == POPT_CONT_INT_PROT_MERKLE)
View
@@ -137,7 +137,8 @@ void Availability::addBinmap(binmap_t * binmap)
void Availability::set(uint32_t channel_id, binmap_t& binmap, bin_t target)
{
if (DEBUGAVAILABILITY)
fprintf(stderr, "%s #%" PRIu32 " Availability -> setting %s (%llu)\n",tintstr(),channel_id,target.str().c_str(),target.toUInt());
fprintf(stderr, "%s #%" PRIu32 " Availability -> setting %s (%llu)\n",tintstr(),channel_id,target.str().c_str(),
target.toUInt());
if (false)
for (int i=0; i<connections_; i++)
@@ -243,7 +244,8 @@ void Availability::removeBin(bin_t bin, int idx)
}
if (DEBUGAVAILABILITY)
fprintf(stderr, "Availability: search bin %s [%llu] on rarity %d [%s] ", bin.str().c_str(), bin.toUInt(), idx, rarity_[idx]->is_empty()?"empty":"full");
fprintf(stderr, "Availability: search bin %s [%llu] on rarity %d [%s] ", bin.str().c_str(), bin.toUInt(), idx,
rarity_[idx]->is_empty()?"empty":"full");
// if the bin is full at this rarity level, set it to empty
// and propagate the info to higher idx of the array
// (idx = availability of content)
View
@@ -35,7 +35,8 @@ void MovingAverageSpeed::AddPoint(uint64_t amount)
}
tint t = usec_time();
speed_ = (speed_ * ((double)(t_end_ - t_start_)/((double)TINT_SEC)) + (double)amount) / ((t - t_start_)/((double)TINT_SEC) + 0.0001);
speed_ = (speed_ * ((double)(t_end_ - t_start_)/((double)TINT_SEC)) + (double)amount) / ((t - t_start_)/((
double)TINT_SEC) + 0.0001);
t_end_ = t;
if (t_start_ < t - speed_interval_)
t_start_ = t - speed_interval_;
Oops, something went wrong.

0 comments on commit 320bf24

Please sign in to comment.