Changeset 1094

Show
Ignore:
Timestamp:
06/10/09 12:25:38 (9 months ago)
Author:
rakshasa
Message:

* Added flag to bencode when unordered bencoded strings are read.

Location:
trunk/libtorrent/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/libtorrent/src/download/download_constructor.cc

    r1072 r1094  
    133133    throw internal_error("parse_info received an already initialized Content object."); 
    134134 
     135  if (b.flags() & Object::flag_unordered) 
     136    throw input_error("Download has unordered info dictionary."); 
     137 
    135138  uint32_t chunkSize = b.get_key_value("piece length"); 
    136139 
  • trunk/libtorrent/src/torrent/object.h

    r1080 r1094  
    7676  static const uint32_t mask_public   = ~mask_internal; 
    7777 
     78  static const uint32_t flag_unordered = 0x100;    // bencode dictionary was not sorted 
     79 
    7880  enum type_type { 
    7981    TYPE_NONE, 
     
    109111  void                set_flags(uint32_t f)                   { m_flags |= f & mask_public; } 
    110112  void                unset_flags(uint32_t f)                 { m_flags &= ~(f & mask_public); } 
     113 
     114  void                set_internal_flags(uint32_t f)          { m_flags |= f & (mask_internal & ~mask_type); } 
     115  void                unset_internal_flags(uint32_t f)        { m_flags &= ~(f & (mask_internal & ~mask_type)); } 
    111116 
    112117  // Add functions for setting/clearing the public flags. 
  • trunk/libtorrent/src/torrent/object_stream.cc

    r1093 r1094  
    9797      Object::list_iterator itr = object->as_list().insert(object->as_list().end(), Object()); 
    9898      object_read_bencode(input, &*itr, depth); 
     99 
     100      if (itr->flags() & Object::flag_unordered) 
     101        object->set_internal_flags(Object::flag_unordered); 
    99102    } 
    100103 
     
    108111      break; 
    109112 
    110     //    Object::string_type last; 
     113    Object::string_type last; 
    111114 
    112115    while (input->good()) { 
     
    121124        break; 
    122125 
    123       //      if (last >= str) 
    124       //        break; 
    125  
    126       object_read_bencode(input, &object->as_map()[str], depth); 
    127  
    128       //      str.swap(last); 
     126      if (last >= str) 
     127        object->set_internal_flags(Object::flag_unordered); 
     128 
     129      Object* value = &object->as_map()[str]; 
     130      object_read_bencode(input, value, depth); 
     131 
     132      if (value->flags() & Object::flag_unordered) 
     133        object->set_internal_flags(Object::flag_unordered); 
     134 
     135      str.swap(last); 
    129136    } 
    130137 
  • trunk/libtorrent/src/torrent/poll_kqueue.cc

    r1074 r1094  
    5555#endif 
    5656 
     57#include <assert.h> 
     58 
    5759namespace torrent { 
    5860 
     
    8991PollKQueue::modify(Event* event, unsigned short op, short mask) { 
    9092  // Flush the changed filters to the kernel if the buffer is full. 
    91   if (m_changedEvents == m_table.size()) 
    92     flush_events(); 
    93  
    9493  if (m_changedEvents == m_maxEvents) { 
    9594    if (kevent(m_fd, m_changes, m_changedEvents, NULL, 0, NULL) == -1)