{"action":"created","issue":{"url":"https://api.github.com/repos/stripydog/kplex/issues/11","repository_url":"https://api.github.com/repos/stripydog/kplex","labels_url":"https://api.github.com/repos/stripydog/kplex/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/stripydog/kplex/issues/11/comments","events_url":"https://api.github.com/repos/stripydog/kplex/issues/11/events","html_url":"https://github.com/stripydog/kplex/issues/11","id":146023380,"number":11,"title":"preamble not sent on tcp client persist=fromstart reconnect","user":{"login":"bakerkj","id":5491232,"avatar_url":"https://avatars.githubusercontent.com/u/5491232?v=3","gravatar_id":"","url":"https://api.github.com/users/bakerkj","html_url":"https://github.com/bakerkj","followers_url":"https://api.github.com/users/bakerkj/followers","following_url":"https://api.github.com/users/bakerkj/following{/other_user}","gists_url":"https://api.github.com/users/bakerkj/gists{/gist_id}","starred_url":"https://api.github.com/users/bakerkj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakerkj/subscriptions","organizations_url":"https://api.github.com/users/bakerkj/orgs","repos_url":"https://api.github.com/users/bakerkj/repos","events_url":"https://api.github.com/users/bakerkj/events{/privacy}","received_events_url":"https://api.github.com/users/bakerkj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-05T15:23:43Z","updated_at":"2016-04-05T20:05:05Z","closed_at":null,"body":"In TCP client persist=fromstart mode the preamble fails to send on reconnect.\r\n\r\nThe preamble structure appears to be created, then assigned to ift->shared->preamble, then used to send the initial preamble.  Unfortunately it is then prompty freed.  So when the reconnect goes to resend the preamble it ends up sending the preamble data structure which has previously been freed.\r\n\r\nI suggest the following diff:\r\n\r\ndiff --git a/tcp.c b/tcp.c                                                                                                                                                                                                                                                                                                                          \r\nindex f4dc6da..314b81f 100644                                                                                                                                                                                                                                                                                                                       \r\n--- a/tcp.c                                                                                                                                                                                                                                                                                                                                         \r\n+++ b/tcp.c                                                                                                                                                                                                                                                                                                                                         \r\n@@ -1107,8 +1107,6 @@ iface_t *init_tcp(iface_t *ifa)\r\n         if (connection) {                                                                                                                                                                                                                                                                                                                          \r\n             if (preamble) {                                                                                                                                                                                                                                                                                                                        \r\n                 do_preamble(ift,preamble);                                                                                                                                                                                                                                                                                                         \r\n-                free(preamble->string);                                                                                                                                                                                                                                                                                                            \r\n-                free(preamble);                                                                                                                                                                                                                                                                                                                    \r\n             }                                                                                                                                                                                                                                                                                                                                      \r\n             ifa->read=do_read;                                                                                                                                                                                                                                                                                                                     \r\n             ifa->write=write_tcp;                                                                                                                                                                                                                                                                                                                  \r\n"},"comment":{"url":"https://api.github.com/repos/stripydog/kplex/issues/comments/205970829","html_url":"https://github.com/stripydog/kplex/issues/11#issuecomment-205970829","issue_url":"https://api.github.com/repos/stripydog/kplex/issues/11","id":205970829,"user":{"login":"bakerkj","id":5491232,"avatar_url":"https://avatars.githubusercontent.com/u/5491232?v=3","gravatar_id":"","url":"https://api.github.com/users/bakerkj","html_url":"https://github.com/bakerkj","followers_url":"https://api.github.com/users/bakerkj/followers","following_url":"https://api.github.com/users/bakerkj/following{/other_user}","gists_url":"https://api.github.com/users/bakerkj/gists{/gist_id}","starred_url":"https://api.github.com/users/bakerkj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakerkj/subscriptions","organizations_url":"https://api.github.com/users/bakerkj/orgs","repos_url":"https://api.github.com/users/bakerkj/repos","events_url":"https://api.github.com/users/bakerkj/events{/privacy}","received_events_url":"https://api.github.com/users/bakerkj/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T20:05:05Z","updated_at":"2016-04-05T20:05:05Z","body":"looks good"}}