Changeset ad49c9d96804ded80d32f8bb271ad728841209ce
- Timestamp:
- 06/21/2010 03:32:04 PM (2 years ago)
- Author:
- Adrien Demarez <adrien.demarez@…>
- Parents:
- 87b9442439e824bb10ace9cbb48d5a40bea6734b
- git-committer:
- Adrien Demarez <adrien.demarez@…> (06/21/2010 03:32:04 PM)
- Message:
-
Fix crash because freeing the pcap context inside the pcap callback
- Location:
- src
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r33d17dc
|
rad49c9d
|
|
| 42 | 42 | : dbus(dbus_engine), thp(NULL), |
| 43 | 43 | last_getservices(0), |
| 44 | | running(false) |
| | 44 | running(false), |
| | 45 | reconnect_thp(false) |
| 45 | 46 | { |
| 46 | 47 | } |
| … |
… |
|
| 54 | 55 | { |
| 55 | 56 | thp_engine_check_fd(thp, rfds, wfds); |
| | 57 | if (reconnect_thp && reconnect() == ERROR_NO_ERROR) |
| | 58 | reconnect_thp = false; |
| 56 | 59 | } |
| 57 | 60 | |
| … |
… |
|
| 83 | 86 | } |
| 84 | 87 | |
| 85 | | void wimax_thp::reconnect() |
| | 88 | int wimax_thp::reconnect() |
| 86 | 89 | { |
| 87 | 90 | wimax_debug("disconnecting\n"); |
| | 91 | int sockfd = thp_engine_get_fd(thp); |
| 88 | 92 | thp_engine_free(thp); |
| 89 | | int sockfd = thp_engine_get_fd(thp); |
| 90 | 93 | FD_CLR(sockfd, saved_rfds); |
| 91 | 94 | sleep(3); |
| 92 | 95 | running = false; |
| 93 | 96 | |
| 94 | | if (connect(networkInterface.c_str(), saved_sockmax, saved_rfds) != ERROR_NO_ERROR) |
| | 97 | if (connect(networkInterface.c_str(), saved_sockmax, saved_rfds) != ERROR_NO_ERROR) { |
| 95 | 98 | wimax_warn("Could not reconnect to THP"); |
| 96 | | else |
| | 99 | return -ERROR_FAILURE; |
| | 100 | } else { |
| 97 | 101 | wimax_debug("Reconnected to THP\n"); |
| | 102 | return ERROR_NO_ERROR; |
| | 103 | } |
| 98 | 104 | } |
| 99 | 105 | |
-
|
r33d17dc
|
rad49c9d
|
|
| 35 | 35 | void check_fd(fd_set *rfds, fd_set *wfds); |
| 36 | 36 | int connect(const std::string &interface, int *sockmax, fd_set *rfds); |
| 37 | | void reconnect(); |
| | 37 | int reconnect(); |
| 38 | 38 | virtual int handle(const char *name, uint8_t *ptr, size_t length); |
| 39 | 39 | virtual int handle_ack(uint16_t ack_nb) { return ERROR_NO_ERROR; }; |
| … |
… |
|
| 49 | 49 | int handle_log(uint8_t *ptr, size_t length); |
| 50 | 50 | int send(uint8_t *data, size_t length, uint16_t *seq_nb = NULL); |
| 51 | | |
| 52 | | protected: |
| 53 | 51 | wimax_ms_dbus *dbus; |
| 54 | 52 | std::string networkInterface; |
| | 53 | bool reconnect_thp; |
| 55 | 54 | |
| 56 | 55 | private: |
-
|
rc373b92
|
rad49c9d
|
|
| 201 | 201 | status, error, rxbytes); |
| 202 | 202 | if (state == BFH_STATE_START_APPLI) |
| 203 | | reconnect(); |
| | 203 | reconnect_thp = true; |
| 204 | 204 | return ERROR_NO_ERROR; |
| 205 | 205 | } |
-
|
r4ec3361
|
rad49c9d
|
|
| 114 | 114 | engine->services[0].title = strdup("GetServices"); |
| 115 | 115 | engine->services[0].id = 1; |
| 116 | | |
| 117 | 116 | return engine; |
| 118 | 117 | } |
| … |
… |
|
| 126 | 125 | pcap_close(engine->pcap_handle); |
| 127 | 126 | free(engine); |
| | 127 | engine = NULL; |
| 128 | 128 | } |
| 129 | 129 | |
| … |
… |
|
| 337 | 337 | static int fragbuffer_index = 0; |
| 338 | 338 | |
| | 339 | if (!engine || !ptr) |
| | 340 | return -ERROR_FAILURE; |
| | 341 | |
| 339 | 342 | if (length < sizeof(*transport)) |
| 340 | 343 | { |