MiMicSDK
Revision | 409427299ecc6e03a6a8fdf39edb0dc70a100e27 (tree) |
---|---|
Zeit | 2014-06-25 12:00:30 |
Autor | nyatla <nyatla@4719...> |
Commiter | nyatla |
websocketのペイロードキャッシュの問題を解消
git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@376 47198e57-cb75-475f-84c4-a814cd6f29e0
@@ -1,7 +1,7 @@ | ||
1 | 1 | #include "NyLPC_cMiMicEnv.h" |
2 | 2 | #include "../uip/NyLPC_cUipService_protected.h" |
3 | 3 | |
4 | -const static char* VERSION="MiMic/1.5.7"; | |
4 | +const static char* VERSION="MiMic/1.5.8"; | |
5 | 5 | |
6 | 6 | #if NyLPC_MCU==NyLPC_MCU_LPC4088 |
7 | 7 | const static char* MCU="LPC4088"; |
@@ -324,7 +324,7 @@ NyLPC_TBool NyLPC_cModWebSocket_canRead(const NyLPC_TcModWebSocket_t* i_inst) | ||
324 | 324 | void NyLPC_cModWebSocket_update(NyLPC_TcModWebSocket_t* i_inst,NyLPC_TUInt32 i_time_out) |
325 | 325 | { |
326 | 326 | const NyLPC_TUInt8* rx; |
327 | - NyLPC_TInt32 rs; | |
327 | + NyLPC_TInt32 rs,rt; | |
328 | 328 | NyLPC_TUInt16 header_size; |
329 | 329 | NyLPC_TUInt8 w8[2]; |
330 | 330 | if(i_inst->_payload_st==NyLPC_TcModWebSocket_ST_CLOSED){ |
@@ -382,6 +382,7 @@ START: | ||
382 | 382 | memcpy(i_inst->_frame_mask,(rx+header_size-4),4); |
383 | 383 | NyLPC_TUInt8_setBit(i_inst->_frame_flags_bits,FLAGS_MASK_BIT); |
384 | 384 | } |
385 | + //ペイロードポインターのリセット | |
385 | 386 | i_inst->payload_ptr=0; |
386 | 387 | |
387 | 388 | //パケットサイズの確定(基本ヘッダ+マスク) |
@@ -421,7 +422,12 @@ START: | ||
421 | 422 | //Timeout |
422 | 423 | goto Timeout; |
423 | 424 | } |
424 | - //読み込みサイズを決定 | |
425 | + //読出し可能なサイズを決定 | |
426 | + rt=i_inst->payload_size-i_inst->payload_ptr; | |
427 | + if(rs>rt){ | |
428 | + rs=rt; | |
429 | + } | |
430 | + //パケットを破棄 | |
425 | 431 | NyLPC_iHttpPtrStream_write(NyLPC_cHttpdConnection_refStream(i_inst->_ref_connection),rx,rs); |
426 | 432 | NyLPC_iHttpPtrStream_rseek(NyLPC_cHttpdConnection_refStream(i_inst->_ref_connection),rs); |
427 | 433 | i_inst->payload_ptr+=rs; |
@@ -441,7 +447,12 @@ START: | ||
441 | 447 | //Timeout |
442 | 448 | goto Timeout; |
443 | 449 | } |
444 | - //読み込みサイズを決定 | |
450 | + //読出し可能なサイズを決定 | |
451 | + rt=i_inst->payload_size-i_inst->payload_ptr; | |
452 | + if(rs>rt){ | |
453 | + rs=rt; | |
454 | + } | |
455 | + //パケットを破棄 | |
445 | 456 | NyLPC_iHttpPtrStream_rseek(NyLPC_cHttpdConnection_refStream(i_inst->_ref_connection),rs); |
446 | 457 | i_inst->payload_ptr+=rs; |
447 | 458 | } |
@@ -502,7 +513,13 @@ NyLPC_TInt16 NyLPC_cModWebSocket_readCB(NyLPC_TcModWebSocket_t* i_inst,NyLPC_TcM | ||
502 | 513 | //Timeout |
503 | 514 | goto Timeout; |
504 | 515 | } |
505 | - rd=0;//読みだしたバイト数 | |
516 | + //読出し可能な残りサイズを計算して上書き | |
517 | + rd=i_inst->payload_size-i_inst->payload_ptr; | |
518 | + if(rs>rd){ | |
519 | + rs=rd; | |
520 | + } | |
521 | + //読みだしたバイト数をリセット | |
522 | + rd=0; | |
506 | 523 | //アンマスク |
507 | 524 | if(NyLPC_TUInt8_isBitOn(i_inst->_frame_flags_bits,FLAGS_MASK_BIT)){ |
508 | 525 | //マスク有の時 |