Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove delay_socket #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions ngrep.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ struct in_addr net, mask;
*/

struct timeval prev_ts = {0, 0}, prev_delay_ts = {0,0};
#if defined(_WIN32)
struct timeval delay_tv;
FD_SET delay_fds;
SOCKET delay_socket = 0;
#endif

void (*print_time)() = NULL, (*dump_delay)() = dump_delay_proc_init;

Expand Down Expand Up @@ -1308,27 +1303,7 @@ void dump_delay_proc(struct pcap_pkthdr *h) {
}

#ifdef _WIN32
{
// grevious hack, yes, but windows sucks. sorry. :( --jordan
if ((delay_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
perror("delay socket creation failed, disabling -D");
Sleep(3000); // give them time to read the message
want_delay = 0;
return;
}

FD_ZERO(&delay_fds);
FD_SET(delay_socket, &delay_fds);

delay_tv.tv_sec = secs;
delay_tv.tv_usec = usecs;

if (select(0, &delay_fds, 0, 0, &delay_tv) == -1)
fprintf(stderr, "WSAGetLastError = %u\n", WSAGetLastError());

closesocket(delay_socket);
delay_socket = 0; // in case someone ^C's out of me
}
Sleep(1000*secs + usecs/1000);
#else
sleep(secs);
usleep(usecs);
Expand Down Expand Up @@ -1500,7 +1475,6 @@ void clean_exit(int32_t sig) {
if (pd_dump) pcap_dump_close(pd_dump);

#if defined(_WIN32)
if (delay_socket) closesocket(delay_socket);
if (want_delay) WSACleanup();
if (usedev) free(usedev);
#endif
Expand Down