Skip to content
Snippets Groups Projects
Select Git revision
  • 6ad3c891bc0c97d2a54f51c27a8158b588ade7b1
  • master default protected
  • android-7.1.2_r28_klist
  • pie-cts-release
  • pie-vts-release
  • pie-cts-dev
  • oreo-mr1-iot-release
  • sdk-release
  • oreo-m6-s4-release
  • oreo-m4-s12-release
  • pie-release
  • pie-r2-release
  • pie-r2-s1-release
  • oreo-vts-release
  • oreo-cts-release
  • oreo-dev
  • oreo-mr1-dev
  • pie-gsi
  • pie-platform-release
  • pie-dev
  • oreo-cts-dev
  • android-o-mr1-iot-release-1.0.4
  • android-9.0.0_r8
  • android-9.0.0_r7
  • android-9.0.0_r6
  • android-9.0.0_r5
  • android-8.1.0_r46
  • android-8.1.0_r45
  • android-n-iot-release-smart-display-r2
  • android-vts-8.1_r5
  • android-cts-8.1_r8
  • android-cts-8.0_r12
  • android-cts-7.1_r20
  • android-cts-7.0_r24
  • android-o-mr1-iot-release-1.0.3
  • android-cts-9.0_r1
  • android-8.1.0_r43
  • android-8.1.0_r42
  • android-n-iot-release-smart-display
  • android-p-preview-5
  • android-9.0.0_r3
41 results

file_contexts

Blame
    • xshu's avatar
      6ad3c891
      Wifi hal - Firmware dump permissions · 6ad3c891
      xshu authored
      we are aiming to improve logging performance by having wifi hal
      directly write to the flash.
      
      Wifi hal need to be able to create, write, and delete files in
      a directory. This will be restricted to userdebug and eng builds only.
      
      Bug: 70170285
      Test: compile, run on device
      Change-Id: Id0cd317411f4c393d7529aa31b501046d7350edb
      6ad3c891
      History
      Wifi hal - Firmware dump permissions
      xshu authored
      we are aiming to improve logging performance by having wifi hal
      directly write to the flash.
      
      Wifi hal need to be able to create, write, and delete files in
      a directory. This will be restricted to userdebug and eng builds only.
      
      Bug: 70170285
      Test: compile, run on device
      Change-Id: Id0cd317411f4c393d7529aa31b501046d7350edb
    EchoServer.cpp 2.35 KiB
    // SPDX-License-Identifier: LGPL-3.0-or-later
    // Copyright © 2020-2021 Florian Fischer
    #include <sys/socket.h>
    #include <sys/types.h>
    
    #include <atomic>
    #include <cerrno>
    #include <chrono>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <string>
    
    #include "Common.hpp"
    #include "Debug.hpp"
    #include "Runtime.hpp"
    #include "emper-config.h"
    #include "io.hpp"
    
    #ifdef EMPER_HAS_COMPARE_H
    #include <compare>
    #endif
    
    const std::string HOST = "::";
    const std::string PORT = "12345";
    
    unsigned int computations_us = 0;
    
    std::atomic<bool> quit = false;
    
    auto main(int argc, char* argv[]) -> int {
    	std::string host = HOST;
    	std::string port = PORT;
    
    	if (argc > 3) {
    		std::cerr << "Usage: " << argv[0] << " [port] [computation_us]" << std::endl;
    		exit(EXIT_FAILURE);
    	}
    
    	if (argc > 1) {
    		port = std::string(argv[1]);
    	}
    
    	if (argc > 2) {
    		computations_us = std::stoi(argv[2]);
    	}
    
    	std::cout << "Echoserver listening on " << host << ":" << port << std::endl;
    
    	Runtime runtime;
    	auto* listener = emper::io::tcp_listener(host, port, [](int socket) {
    		// NOLINTNEXTLINE(modernize-avoid-c-arrays)
    		char buf[1024];
    		while (!quit.load(std::memory_order_consume)) {
    			ssize_t bytes_recv = emper::io::recvAndWait(socket, buf, sizeof(buf), 0);
    			if (unlikely(bytes_recv <= 0)) {
    				// socket was shutdown
    				if (bytes_recv < 0) {
    					LOGE("server read failed:" << strerror(errno));
    				}
    				break;
    			}
    
    			if (unlikely(bytes_recv == 5 && strncmp("quit\n", buf, bytes_recv) == 0)) {
    				quit = true;
    				std::cout << "Echoserver received 'quit' command from client" << std::endl;
    				Runtime::getRuntime()->initiateTermination();
    				break;
    			}
    
    			const auto start = std::chrono::steady_clock::now();
    			const auto deadline = start + std::chrono::microseconds(computations_us);
    			// TODO: The suppressed linter error below may be a false positive
    			// reported by clang-tidy.
    			// NOLINTNEXTLINE(modernize-use-nullptr)
    			while (std::chrono::steady_clock::now() < deadline) {
    			}
    
    			ssize_t bytes_send = emper::io::sendAndWait(socket, buf, bytes_recv, MSG_NOSIGNAL, true);
    			if (unlikely(bytes_recv != bytes_send)) {
    				LOGE("server send failed: " << strerror(errno));
    				break;
    			}
    		}
    
    		emper::io::closeAndForget(socket);
    	});
    
    	if (!listener) {
    		exit(EXIT_FAILURE);
    	}
    
    	runtime.scheduleFromAnywhere(*listener);
    
    	runtime.waitUntilFinished();
    
    	return EXIT_FAILURE;
    }