aboutsummaryrefslogtreecommitdiffstats
path: root/apps/producers
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2017-06-05 16:48:29 +0200
committerMauro Sardara <msardara+fdio@cisco.com>2017-06-05 17:45:15 +0200
commitd22d2b4785e2f4eafc8dda2ae032931f89c7e45f (patch)
tree47fa6879217c4b08e8a78efc33b8cd007a110866 /apps/producers
parent52ab9bf241528b0cb1d24384d22b017391be2899 (diff)
- Added new interface between applications and library:
- Application retrieve resources using the common HTTP url format. - Translation between network names and application names performed by the library - Added basic error handling - Added utils for http connections - Added support for differetn build types (DEBUG, RELEASE, RELEASE with debug symbols, RELEASE with min size executable) - Added support for iOS Change-Id: I8ba2a5d8bd70a4f7721e1bbc2efe3fb81ed2c98c Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'apps/producers')
-rwxr-xr-xapps/producers/icnet_producer_test.cc55
1 files changed, 9 insertions, 46 deletions
diff --git a/apps/producers/icnet_producer_test.cc b/apps/producers/icnet_producer_test.cc
index c122090a..f35d082a 100755
--- a/apps/producers/icnet_producer_test.cc
+++ b/apps/producers/icnet_producer_test.cc
@@ -13,19 +13,22 @@
* limitations under the License.
*/
-#include "icnet_socket_producer.h"
+#include "icnet_transport_socket_producer.h"
+#include "icnet_utils_daemonizator.h"
#define IDENTITY_NAME "cisco"
namespace icnet {
+namespace transport {
+
class CallbackContainer {
public:
CallbackContainer(unsigned long download_size = 0)
: buffer_(1400, 'X'), final_chunk_number_(0) {
content_object_.setContent((uint8_t *) buffer_.c_str(), 1400);
if (download_size > 0) {
- final_chunk_number_ = static_cast<uint64_t>(std::ceil(download_size / 1400.0));
+ final_chunk_number_ = static_cast<uint64_t > (std::ceil(download_size / 1400.0));
}
}
@@ -66,48 +69,6 @@ class Signer {
Name identity_name_;
};
-void becomeDaemon() {
- pid_t process_id = 0;
- pid_t sid = 0;
-
- // Create child process
- process_id = fork();
-
- // Indication of fork() failure
- if (process_id < 0) {
- printf("fork failed!\n");
- // Return failure in exit status
- exit(EXIT_FAILURE);
- }
-
- // PARENT PROCESS. Need to kill it.
- if (process_id > 0) {
- printf("process_id of child process %d \n", process_id);
- // return success in exit status
- exit(EXIT_SUCCESS);
- }
-
- //unmask the file mode
- umask(0);
-
- //set new session
- sid = setsid();
- if (sid < 0) {
- // Return failure
- exit(EXIT_FAILURE);
- }
-
- // Change the current working directory to root.
- chdir("/");
-
- // Close stdin. stdout and stderr
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
- // Really start application
-}
-
int main(int argc, char **argv) {
std::string name = "ccnx:/ccnxtest";
unsigned long download_size = 0;
@@ -135,7 +96,7 @@ int main(int argc, char **argv) {
}
if (daemon) {
- becomeDaemon();
+ utils::Daemonizator::daemonize();
}
CallbackContainer stubs(download_size);
@@ -168,9 +129,11 @@ int main(int argc, char **argv) {
return 0;
}
+} // end namespace transport
+
} // end namespace icnet
int main(int argc, char **argv) {
- return icnet::main(argc, argv);
+ return icnet::transport::main(argc, argv);
}