meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

peerhood:solution [2010/03/22 11:20]
julaakko
peerhood:solution [2011/09/02 12:05]
Line 1: Line 1:
-====== Solutions for PeerHood Problems ====== 
-See development [[conventions#​changes]] procedure. 
- 
-===== Memory consumption ===== 
- 
-==== Problem description ==== 
- 
-PeerHood did reserve vast amount of (virtual) memory when started, ~21 MB with bluetooth plugin only (~44 MB when using WLAN and bluetooth) when only the daemon was running. The [[peerhood:​peerhood_performance_and_memory_usage|testing]] of memory consumption was performed for this reason to find out what uses or reserves that memory. [[peerhood:​peerhood_performance_and_memory_usage#​exmap1|First test]] and [[peerhood:​peerhood_performance_and_memory_usage#​exmap2|second test]] indicated that the memory was only reserved for some purpose while only small portion of it was used. With [[peerhood:​peerhood_performance_and_memory_usage#​rd_test_with_debugger|third test]] the reason was found: pthread library does reserve a big memory space for each thread when thread is started, the size of the memory space is the same as the default stack size in operating system (see [[peerhood:​peerhood_performance_and_memory_usage#​testing_the_memory_usage_of_threads|testing]]) 
- 
-==== Problem solution ==== 
- 
-__Solution__ to this was to reduce the stack size, it can be done by setting a stack size for each thread in program code. See [[peerhood:​peerhood_performance_and_memory_usage#​solution|solution]] on the [[peerhood:​peerhood_performance_and_memory_usage|memory analysis pages]]. 
- 
-**THIS ISN'T YET IMPLEMENTED INTO THE CODE** 
- 
-===== WLAN plugin ===== 
- 
-==== Problem description ====  
- 
-  - If plugin exists and it is loaded PeerHood daemon segfaults if there is no specified WLAN-interface up and running. This happens only when starting the daemon. - [[wiki:​user:​julaakko]] 
-  - WLAN plugin stops at first write error in ''​WLANPlugin::​InquiryThread''​. There should be at least some tolerance for failures. - [[wiki:​user:​julaakko]] 
- 
-==== Problem solution ==== 
-  - Fixed in Maemo with listener, could be solved by creating a listener for WLAN state in Linux. 
-  - Increased the tolerance to 10, defined in the WLANPlugin.cc. Plugin stops when amount of errors is reached, when there are same amount of successful writes the counter for errorous writes is zeroed. This is just a temporary solution, the plugin doesn'​t crash when e.g changing network (tolerance can be increased, it should be defined in config..). 
- 
- 
-===== Genral bugs in code ===== 
- 
-=== HasData() -function === 
-<del> 
-The function reaches end of non-void function in error situations although it should return a ''​boolean''​-value.</​del> ​ 
- 
-FIXED - [[wiki:​user:​julaakko]] 
- 
-===== Slight problems with Bluetooth ==== 
- 
-==== Problem description ====  
- 
-Briefly: after PeerHood daemon (alone, no services or applications using the daemon) has been running for ~7 hours or more it either crashes (segfault or in latest tests assertion error in ''​CBTConnection''​ line 40) or starts reporting -1 responses from surrounding bluetooth devices and also errors reported by ''​BTPlugin::​Inquirythread''​ : <​code>​Too many open files</​code>​ and 
-<​code>​Device or resource busy</​code>​ 
-First could be result from ''​hci_inquiry''​ -function functionality,​ second could be from thread safety issue in BlueZ bluetooth library. For further information,​ see: [[peerhood:​peerhood_bluetooth_feature_and_testing|a possible feature found in Bluetooth library/​hardware functionality - incl. testing]]. 
- 
-==== Problem solution ==== 
- 
-Copied the inquiry-function from hci.h and modified it not to open new socket on every inquiry. Currently PeerHood uses a raw socket to bluetooth device to control it via ioctl commands, currently only inquiry and adapter reset are using this. New socket is created when the bluetooth plugin is loaded. This reduces the errors mentioned in the problem description,​ there still exists some faulty socket/​handle usages which at some point can cause "Too many open files" error. ​