Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[tcp core][RFC] Wait for TCP to safely close
After some discussion with Piotr and Michael, I think it might be an acceptable solution for the issue that gPXE leaves remote peer TCP in undesired state. The reason I don't mark activity_start at somewhere like tcp_open or ESTABLISHED is that sanboot do not close the TCP connection before hand of the control to OS.
- Loading branch information
Showing
7 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* The original idea is from: Michael Brown <mbrown@fensystems.co.uk>. | ||
* Implemented into gPXE by: Guo-Fu Tseng <cooldavid@cooldavid.org>. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of the | ||
* License, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
#include <gpxe/timer.h> | ||
#include <gpxe/process.h> | ||
#include <gpxe/activity.h> | ||
|
||
/** @file | ||
* | ||
* Activities | ||
* | ||
* We implement a facility to keep the processes running while waiting | ||
* for some critical events to complete. | ||
*/ | ||
|
||
|
||
/** Currently waiting activities */ | ||
static unsigned int num_activities = 0; | ||
|
||
/** | ||
* Start an activity | ||
*/ | ||
void activity_start ( void ) { | ||
num_activities++; | ||
} | ||
|
||
/** | ||
* Stop an activity | ||
*/ | ||
void activity_stop ( void ) { | ||
num_activities--; | ||
} | ||
|
||
/** | ||
* Wait for activities to complete | ||
* | ||
* @v max_timeout The max waiting time in tenths of a second. | ||
* @ret boolean If all the activities are cleared. | ||
*/ | ||
int activity_wait ( unsigned long max_timeout ) { | ||
max_timeout = currticks() + ( max_timeout * TICKS_PER_SEC ) / 10; | ||
while ( num_activities && currticks() < max_timeout ) { | ||
step(); | ||
} | ||
return !num_activities; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _GPXE_ACTIVITY_H | ||
#define _GPXE_ACTIVITY_H | ||
|
||
/** @file | ||
* | ||
* gPXE activity API | ||
* | ||
* The activity API provides facility to keep the processes running | ||
* while waiting for some critical events to complete. | ||
* | ||
* It is suggested that we don't call activity_wait() within any | ||
* process's scope. | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
extern void activity_start ( void ); | ||
extern void activity_stop ( void ); | ||
|
||
/* Default timeout for 1 second */ | ||
#define ACTIVITY_TIMEOUT 10 | ||
|
||
/** | ||
* max_timeout is in tenths of a second | ||
*/ | ||
extern int activity_wait ( unsigned long max_timeout ); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters