On the mental process of dealing with a C++ server program that hangs frequently

1. Project background

     a. Project requirements

      I'm currently working on a project about robot image recognition. There are reasons for this. There are a lot of pits, big and small, to share. Approximate requirements: The client (sending request side) sends the robot inspection pictures in real time, and sends the picture stream to the server in Json format through the Http interface protocol. 

     b. Organizational structure and operating environment

       The client (data collected by the robot in real time) sends a picture stream (about 3 pictures per second) to the server (picture analysis and recognition) and calls the recognition algorithm, and finally returns the recognized picture to the requester.

 2. Problem overview

  a. The request header is not written and the response does not return data (the problem of Http message format)

   b. The local file has no read/write permission, which causes the program to exit unexpectedly

   c. Some local variables are not initialized, and null pointers and wild pointers appear, which leads to abnormal Dump of the program

   d. Data out of bounds exception

   The dynamic memory of e.new allocator and other dynamic applications is not released in time or has not been released and the corresponding delete free

   f. Multithreaded file access causes memory overflow or memory leaks and other issues

      Memory overflow: Shen but not enough

      Memory leak: application but not yet paid

  g. The request response delay time is too long, causing the client to not receive the response data in time.

  h.Libevent (http high concurrency processing framework based on Epoll encapsulation) version is too low (the essence is that the low version dynamic inventory is defective ==)

3. Analysis and processing process

4. Technology used

Single-threaded processing ==> multi-threaded

Libevent high concurrency http processing framework

Thread lock

Request client framework (curl)

5. Learned content

A good attitude is the key to dealing with problems, and a step-by-step strategy is a booster for dealing with problems;

 

     

 

Guess you like

Origin blog.csdn.net/xiaoshunzi111/article/details/104605481