diff options
| author | 姜鹏辉 <[email protected]> | 2020-12-02 18:21:14 +0800 |
|---|---|---|
| committer | 姜鹏辉 <[email protected]> | 2020-12-02 18:21:14 +0800 |
| commit | 85b59f389a2bb41735b6c587f53961d0d3a5ed42 (patch) | |
| tree | 711a188a597f4f4912a6e5ef869f296d32c114b2 | |
| parent | 1555fb11f82f2bc560fa116c9b752e0f2081d045 (diff) | |
fix bugs about file_length wrong
| -rw-r--r-- | qq_file_send.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/qq_file_send.c b/qq_file_send.c index 359e7f5..b78352a 100644 --- a/qq_file_send.c +++ b/qq_file_send.c @@ -29,13 +29,14 @@ typedef struct { uint8_t send_type; // OFFLINE_SEND char uuid[UUID_LENGTH+1]; - uint16_t content_len; - char filename[NAME_SIZE]; + uint16_t content_len; // content length in current packet + char filename[NAME_SIZE]; struct nirvana_streaming_ctx *ctx; - uint8_t next_flag; - uint64_t file_len; - uchar curdir; - uint id; + uint8_t next_flag; // 1: next packet contains separator + // 0: not contain + uint64_t *file_len; // file length + uchar curdir; + uint id; // same like file count , from 0 to start }qq_pme_info,*qq_pme_info_p; typedef struct @@ -57,6 +58,7 @@ typedef struct uint id; char filename[NAME_SIZE]; struct nirvana_streaming_ctx *ctx; + uint64_t *file_len; // file length }file_info; uint capture_file_cnt = 0; @@ -112,6 +114,7 @@ int parse_separator(char **payload,int payload_len,struct_separator_feature sepa } qq_pme_info_p qq_pme = *pme; strncpy(qq_pme->uuid,(*payload) + separator_feature.uuid_deviation,uuid_len); + qq_pme->uuid[uuid_len+1] = '\0'; //printf("this uuid:%s\n",qq_pme->uuid); (*payload)+=separator_feature.content_deviation; @@ -283,12 +286,18 @@ int match_uuid(qq_pme_info **pme) // new file create file_info *newfile; newfile = (file_info *)malloc(sizeof(file_info)); - sprintf(qq_pme->filename,"%s/%d-%s",save_directory,capture_file_cnt,qq_pme->uuid); + qq_pme->id = capture_file_cnt; - newfile->id = capture_file_cnt; capture_file_cnt++; + newfile->id = qq_pme->id; + sprintf(qq_pme->filename,"%s/%d-%s",save_directory,qq_pme->id,qq_pme->uuid); + strncpy(newfile->filename,qq_pme->filename,strlen(qq_pme->filename)); - qq_pme->file_len = 0; + + uint64_t *file_len = (uint64_t *)malloc(sizeof(uint64_t)); + *file_len = 0; + qq_pme->file_len = file_len; + newfile->file_len = file_len; #ifdef NIRVANA // nirvana section struct nirvana_streaming_ctx *ctx; @@ -323,7 +332,7 @@ int match_uuid(qq_pme_info **pme) newfile->ctx = ctx; #endif MESA_handle_runtime_log(runtime_log,RLOG_LV_INFO,"match","create %d file\tuuid:%s ",qq_pme->id,qq_pme->uuid); - MESA_htable_add(file_htable,(u_char *) qq_pme->uuid, strlen(qq_pme->uuid), (void *)newfile); + MESA_htable_add(file_htable,(u_char *) qq_pme->uuid, UUID_LENGTH, (void *)newfile); return 0; } else @@ -331,6 +340,7 @@ int match_uuid(qq_pme_info **pme) // there is a file point in htable // so change the pme qq_pme->id = thisfile->id; + qq_pme->file_len = thisfile->file_len; MESA_handle_runtime_log(runtime_log,RLOG_LV_INFO,"match","file %d existed,uuid:%s",qq_pme->id,qq_pme->uuid); strncpy(qq_pme->filename,thisfile->filename,strlen(thisfile->filename)); #ifdef NIRVANA @@ -455,7 +465,8 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s content_len = qq_pme->content_len; match_uuid(&qq_pme); } - qq_pme->file_len += content_len; + *(qq_pme->file_len) += content_len; + MESA_handle_runtime_log(runtime_log,RLOG_LV_DEBUG,"match","file %d saved %d Bytes, content_len:%d",qq_pme->id,*(qq_pme->file_len),content_len); if(locally_save == 1) { //save file to disk @@ -484,6 +495,7 @@ int suggestion_inform_callback(struct suggest_receive_info *info, struct nirvana return 0; } + void nirvana_client_init() { struct nirvana_parameter *parameter; |
